Search code examples
flutterdartflutter-isar

Flutter Isar-ORM obtaining all related links from collection


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);

Solution

  • I found out

    solution is:

    teacher = isarInstance.collection<Teacher>().where().findFirstSync();
    
    print(teacher.value!.students);