diameter/lib/models/basal.dart

38 lines
929 B
Dart
Raw Normal View History

import 'package:diameter/main.dart';
2021-10-22 23:08:09 +00:00
import 'package:diameter/models/basal_profile.dart';
import 'package:diameter/objectbox.g.dart';
@Entity(uid: 1467758525778521891)
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
}
}