2016-04-08 35 views
3

React Native和Realm noob here!在Realm上为React Native过滤具有null属性的对象

我想加载一个特定属性为空的对象。

我试着过滤它们是这样的:

let goals = Modal.objects('goal').filtered('SubGoalOf == $0', null); 

我也试过这样:

let goals = Modal.objects('goal').filtered('SubGoalOf == $0', {}); 

但是有错误,如“价值不是一个对象”和“对象不是境界目的”。没有过滤方法的查询正常工作并返回所有内容。但这不完全是我的目标。

这将是模式:

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}, 
    } 
} 

这将是巨大的,如果有人可以帮助我。谢谢。

回答

3

目前,Realm React Native不支持查询null。这种增强是通过这个问题追踪:

所有可选类型实现/测试空查询

https://github.com/realm/realm-js/issues/162

+0

更新:目前*不*支持此版本> ='0.12.0 ' –

相关问题