Flutter Isar-ORM obtaining all related links from collection

140 views Asked by At

You suppose we created this collection for Isar:

@collection
class Teacher {
  Id id;

  late String subject;

  @Backlink(to: 'teacher')
  final student = IsarLinks<Student>();
}

as you can see student is a Isar link and i research all Isar documentation to know how can i have all student from Teacher like a tree such as: teacher.students

for example:

teacher = isarInstance.collection<Teacher>().where().findFirstSync();

print(teacher.students);
1

There are 1 answers

0
DolDurma On BEST ANSWER

I found out

solution is:

teacher = isarInstance.collection<Teacher>().where().findFirstSync();

print(teacher.value!.students);