objectbox-dart
objectbox-dart copied to clipboard
_QueryStringVectorProperty.notContains
I have an object that looks like
@Entity()
class Post {
int id;
List<String>? readByIds
// other properties
queryObject({this.id = 0, this.readByIds});
}
And I would like to be able to retrieve Posts I have not read. It would be useful if the generated metadata had the .notContains function for this kind of situation. i.e box.query(Post_.notContains(userId))
In my situation I know all the ids of who could read it, and so have added an extra property that is the inverse readByIds:
@Entity()
class Post {
int id;
List<String>? readByIds;
List<String>? notReadByIds;
// other properties
queryObject({this.id = 0, this.readByIds, this.notReadByIds});
}
but the duplication makes this undesirable
Would need to be implemented in the core. I'm raising a feature request there.
BTW, this looks like a good candidate for a separate "table" with the list of which items have been read by which user (assuming that's what you mean by readByIds), e.g.
@Entity()
class Post {
int id;
...
}
@Entity()
class PostReads {
int id;
final post = ToOne<Post>();
final user = ToOne<User>();
}
As this is kind of asking for the notOneOf condition and to track interest in one place, closing this as a duplicate of #591.