Parse.com 查询在 iOS 上不为 null 的列



这应该是一个简单的任务,但它让我感到悲伤。我在数据库中有如下所示的对象:

{
  "objectId": "abcdefg1",
  "comment": null
},
{
  "objectId": "abcdefg2",
  "comment": "Some text as a comment"
}

我尝试仅在iOS上查询具有注释文本的记录。我正在执行以下查询:

PFQuery *query = [PFQuery queryWithClassName:@"Review"];
[query whereKeyExists:@"comment"];

当它被执行时,当我只期望一个结果时,我会得到上面列出的两个结果。有人可以指出我哪里出错了。谢谢!

呃...自然是我才想通的。这是解决方案:

PFQuery *query = [PFQuery queryWithClassName:@"Review"];
[query whereKey:@"comment" notEqualTo:[NSNull null]];

这返回了我期望的一个对象。我需要更好地关注文档。

https://parse.com/docs/ios/guide#objects-data-types

最新更新