简体   繁体   English

Parse.com查询iOS上不为空的列

[英]Parse.com query for column that is not null on iOS

This should be a simple task but it's causing me grief. 这应该是一个简单的任务,但是却使我感到悲伤。 I have objects that look like this in the database: 我的数据库中的对象看起来像这样:

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

I'm trying to query for only records that have comment text on iOS. 我正在尝试仅查询在iOS上具有注释文本的记录。 I'm executing the following query: 我正在执行以下查询:

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

When it's executed I'm getting the two results listed above when I'm expecting only one. 当它执行时,当我期望只有一个时,会得到上面列出的两个结果。 Can someone please point out where I'm going wrong. 有人可以指出我要去哪里了。 Thanks! 谢谢!

Ugh...naturally I just figured it out. gh ...自然地,我只是想通了。 Here is the solution: 解决方法如下:

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

This returns me the one object I expected. 这给了我一个我期望的对象。 I need to pay attention to the documentation better. 我需要更好地注意文档。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM