2021-11-07 20:13:28 +00:00
|
|
|
import 'package:diameter/main.dart';
|
|
|
|
import 'package:diameter/objectbox.g.dart';
|
2021-10-22 23:08:09 +00:00
|
|
|
|
2021-11-07 20:13:28 +00:00
|
|
|
@Entity()
|
2021-10-22 23:08:09 +00:00
|
|
|
class BasalProfile {
|
2021-11-07 20:13:28 +00:00
|
|
|
static final Box<BasalProfile> box = objectBox.store.box<BasalProfile>();
|
|
|
|
|
|
|
|
int id;
|
|
|
|
String name;
|
|
|
|
bool active;
|
|
|
|
String? notes;
|
|
|
|
|
|
|
|
BasalProfile({
|
|
|
|
this.id = 0,
|
|
|
|
this.name = '',
|
|
|
|
this.active = false,
|
|
|
|
this.notes,
|
|
|
|
});
|
|
|
|
|
|
|
|
static BasalProfile? get(int id) => box.get(id);
|
|
|
|
static List<BasalProfile> getAll() => box.getAll();
|
|
|
|
static void put(BasalProfile basalProfile) => box.put(basalProfile);
|
|
|
|
static void remove(int id) => box.remove(id);
|
|
|
|
|
|
|
|
static int activeCount() {
|
|
|
|
Query<BasalProfile> query =
|
|
|
|
box.query(BasalProfile_.active.equals(true)).build();
|
|
|
|
return query.find().length;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setAllInactive() {
|
|
|
|
box.putMany(box.getAll().map((element) {
|
|
|
|
element.active = false;
|
|
|
|
return element;
|
|
|
|
}).toList());
|
2021-10-22 23:08:09 +00:00
|
|
|
}
|
|
|
|
}
|