import 'package:objectbox/objectbox.dart'; abstract class ObjbxDbMgrBase { /// The Store of this app. late final Store store; late final Box objectBox; ObjbxDbMgrBase(this.store) { objectBox = Box(store); } // bool isEmpty() => objectBox.isEmpty(); // List getAll() => objectBox.getAll(); T get(int id) => objectBox.get(id)!; T? getFirst() => objectBox.query().build().findFirst(); Future> getAllAsync() => objectBox.getAllAsync(); Stream> getAllStream(QueryProperty orderProperty, {int orderFlags = 0}) { // Query for all tasks, sorted by their date. // https://docs.objectbox.io/queries final queryBuilder = objectBox.query().order(orderProperty, flags: orderFlags); // Build and watch the query, // set triggerImmediately to emit the query immediately on listen. return queryBuilder .watch(triggerImmediately: true) // Map it to a list of tasks to be used by a StreamBuilder. .map((query) => query.find()); } int put(T obj) => objectBox.put(obj); FutureputAsync(T obj) => objectBox.putAsync(obj); Future>putManyAsync(List objects, {PutMode mode = PutMode.put}) => objectBox.putManyAsync(objects, mode: mode); void remove(int id) => objectBox.removeAsync(id); }