import 'package:diameter/main.dart'; import 'package:objectbox/objectbox.dart'; import 'package:diameter/objectbox.g.dart' show BasalProfile_; @Entity(uid: 3613736032926903785) class BasalProfile { static final Box box = objectBox.store.box(); // properties int id; bool deleted; String name; bool active; String? notes; // constructor BasalProfile({ this.id = 0, this.deleted = false, this.name = '', this.active = false, this.notes, }); // methods static BasalProfile? get(int id) => box.get(id); static void put(BasalProfile basalProfile) => box.put(basalProfile); static List getAll() { QueryBuilder all = box.query(BasalProfile_.deleted.equals(false)); return all.build().find(); } static void remove(int id) { final item = box.get(id); if (item != null) { item.deleted = true; box.put(item); } } static int activeCount() { Query query = box .query(BasalProfile_.active.equals(true) & BasalProfile_.deleted.equals(false)).build(); return query.find().length; } static void setAllInactive() { box.putMany(box.getAll().map((item) { item.active = false; return item; }).toList()); } @override String toString() { return name; } }