How to get data from a relation in an entity in ObjectBox

423 views Asked by At

I'm new to ObjectBox. I have a worklistDocumentNumber, from which I need to get report master data by using query. Can anyone help me with this. I tried by adding some filter conditions in query, but I'm not sure how exactly this works...

@Entity()
class ReportMaster {
  int id;
  String? reportName;
  String? reportContent;

final workList = ToOne<WorkList>();

  ReportMaster({
    this.id = 0,
    required this.reportName,
    required this.reportContent,

  });
}



@Entity()
class WorkList{
  int id;
  String? worklistDocumentNumber;
  String? worklistStatus;


  WorkList({
      this.id = 0 ,
      this.worklistDocumentNumber,
      this.worklistStatus,
});
}

This is my Store

late final Store _store;
late final Box<ReportMaster> _reportMasterBox;


ObjectBox._init(this._store){
  _reportMasterBox = Box<ReportMaster>(_store);

}


static Future<ObjectBox> init() async {
  final store = await openStore();
  return ObjectBox._init(store);
}
1

There are 1 answers

0
Meshkat Shadik On

Learn something about relational database concepts, though ObjectBox depends upon NoSql. But for establishing relations, you should have know some basics, like key!

  • What Primary Keys are?
  • What Foreign Keys are?
  • How two tables are related via Primary and Foreign Key?

After knowing this basics, you can head over to the docs of ObjectBox, it'll be much easier than before!

For knowing the basics You can refer to,

  • w3 schools or
  • javatpoint
  • or anyother youtube video

And for ObjectBox The Official Documentation about Relations in ObjectBox