我创建了一个过滤器类,用于过滤另一个类中的数据,但是为了检查是否应该使用过滤器,我只需要查询该数据,如果它不等于undefined / null。问题是我一直收到以下错误?
Cannot do a query that requires ordering for type: NSNull'
我有以下代码来检查密钥是否有值。
以下键是一个数字:max和min
以下键是一个数组:类型,句号和房间
if ([filter objectForKey:@"min"] && [filter objectForKey:@"min"] > 0) {
[query whereKey:@"type" greaterThanOrEqualTo:[filter objectForKey:@"min"]];
}
if ([filter objectForKey:@"max"] && [filter objectForKey:@"max"] > 0) {
[query whereKey:@"type" lessThanOrEqualTo:[filter objectForKey:@"max"]];
}
if (![filter objectForKey:@"type"] > 0) {
[query whereKey:@"type" containedIn:[filter objectForKey:@"type"]];
}
if (![filter objectForKey:@"period"] > 0) {
[query whereKey:@"period" greaterThanOrEqualTo:[filter objectForKey:@"period"]];
}
if (![filter objectForKey:@"room"] > 0) {
[query whereKey:@"room" containedIn:[filter objectForKey:@"room"]];
}
答案 0 :(得分:1)
我相信你所要做的就是:
[query whereKey:@"{key}" notEqualTo:NSNull.null];
Swift版本:
query?.whereKey("someKey", equalTo: NSNull())