I have 2 classes set up with these relations, with Faults only having 1 equipment, and equipment having many faults.
@Entity()
class Equipment {
int? id;
String adminNumber;
...
@Backlink()
final faults = ToMany<Fault>();
...
}
@Entity()
class Fault {
/// Let objectbox handle ID assigning
int? id;
String uuid;
...
final equipment = ToOne<Equipment>();
...
}
I'm attempting to utilize the backlink to find all equipment that has a connection to a fault, (as equipment can be created without a fault).
But I can't seem to access the faults property of the equipment
final testQuery = _localDbBaseService.faultsBox.query()
..backlink(Equipment_.faults, Equipment_.faults.notNull());
final test = testQuery.build().find();
return test;
"The getter 'faults' isn't defined for the type 'Equipment_'."
I'm pretty sure I have the query backward, but I'm just attempting to figure out how to correctly use backlink. I know I could walk through this forward by querying all faults and then querying all equipment and filtering them like that, but I feel as if backlink should function this way....or am I completely misunderstanding its intention? I can't seem to find many examples relating to Backlinks, especially with in Dart
Oh man, the rubber ducky method helps again, I feel like an idiot. Anyway, for anyone else that stumbles upon this working with backlinks in flutter, you do indeed query the "parent" object
final builder = _localDbBaseService.equipmentBox
.query();
builder.backlink(Fault_.equipment, Fault_.equipment.notNull());
final query = builder.build();
final items = query.find();
return items;