0

I'm new to flutter and Isar. I have the following class

@collection
class RootWord {
  Id id = Isar.autoIncrement;

  @Index()
  late int subCategoryId;

  late String name;
  late List<Word> wordList;
  late bool hide;
}

I have a collection of RootWords and I'm trying to find all the RootWords that contain a certain Word in RootWord.wordList. I'm not familiar with quering lists in Isar so obviously my code is all wrong.

List<RootWord> findRootWords({required Isar isar, required String str) {
    return isar.rootWords.filter().wordListElement((q) =>  q.engWordContains(str, caseSensitive: false));
}

Thank you for helping me

jamesdlin
  • 81,374
  • 13
  • 159
  • 204
Yogi Wannabe
  • 141
  • 7

2 Answers2

0

I also recently started learning Isar. To begin with, make the Word class a separate collection, and then add IsarLink to the RootWord as in the documentation. After that you will be able to make queries

Nikondrat
  • 66
  • 5
0

This works for me.

List<RootWord> findRootWords({required Isar isar, required String searchStr}) {
    return(isar.rootWords.filter().wordListElement((q) => q.engWordContains(searchStr, caseSensitive: false)).findAllSync());
}
Yogi Wannabe
  • 141
  • 7