2021-11-07 20:13:28 +00:00
|
|
|
import 'package:diameter/main.dart';
|
2021-10-22 23:08:09 +00:00
|
|
|
import 'package:diameter/models/basal_profile.dart';
|
2021-11-07 20:13:28 +00:00
|
|
|
import 'package:diameter/objectbox.g.dart';
|
|
|
|
|
2021-11-09 00:17:35 +00:00
|
|
|
@Entity(uid: 1467758525778521891)
|
2021-11-07 20:13:28 +00:00
|
|
|
class Basal {
|
|
|
|
static final Box<Basal> box = objectBox.store.box<Basal>();
|
|
|
|
|
|
|
|
int id;
|
|
|
|
|
|
|
|
@Property(type: PropertyType.date)
|
|
|
|
DateTime startTime;
|
|
|
|
|
|
|
|
@Property(type: PropertyType.date)
|
|
|
|
DateTime endTime;
|
|
|
|
|
|
|
|
double units;
|
|
|
|
|
|
|
|
final basalProfile = ToOne<BasalProfile>();
|
|
|
|
|
|
|
|
Basal({
|
|
|
|
this.id = 0,
|
|
|
|
required this.startTime,
|
|
|
|
required this.endTime,
|
|
|
|
this.units = 0,
|
|
|
|
});
|
|
|
|
|
|
|
|
static Basal? get(int id) => box.get(id);
|
|
|
|
static void put(Basal basal) => box.put(basal);
|
|
|
|
static void remove(int id) => box.remove(id);
|
|
|
|
|
|
|
|
static List<Basal> getAllForProfile(int id) {
|
|
|
|
QueryBuilder<Basal> builder = box.query()..order(Basal_.startTime);
|
|
|
|
builder.link(Basal_.basalProfile, BasalProfile_.id.equals(id));
|
|
|
|
return builder.build().find();
|
2021-10-22 23:08:09 +00:00
|
|
|
}
|
|
|
|
}
|