Reputation: 35
React Native and Realm noob here!
I want to load objects where one particular property is null.
I tried to filter them like this:
let goals = Modal.objects('goal').filtered('SubGoalOf == $0', null);
I've also tried this:
let goals = Modal.objects('goal').filtered('SubGoalOf == $0', {});
But got errors like "Value is not an object" and "object is not Realm Object". Query without filtered method is working perfectly and returning everything. But that's not exactly what I am going for.
This would be the schema:
Goal.schema = {
name: 'goal',
primaryKey: 'id',
properties: {
id: 'string',
createdOn: 'date',
itemName: {type: 'string', indexed: true },
SubGoalOf: {type: 'goal', optional: true},
ShouldNotify: 'bool',
WhenNotify: {type:'date', optional: true},
deadline: {type:'date', optional: true},
isComplete: 'bool',
completedOn: {type:'date', optional: true},
}
}
It would be great, if anyone could help me. Thank you.
Upvotes: 3
Views: 4626
Reputation: 10573
Currently, Realm React Native doesn't support querying for null
. This enhancement is tracked by this issue:
Implement/test null queries for all optional types
https://github.com/realm/realm-js/issues/162
Upvotes: 4