如何制作 Parse.Query.AND?
我需要用 and 连接 Parse.com 中的 2 个查询,我的代码是:
I need to connect 2 queries in Parse.com with an and, my code is:
var queryDeseo1 = new Parse.Query(DeseosModel);
queryDeseo1.equalTo("User", Parse.User.current());
queryDeseo1.equalTo("Deseo", artist);
queryDeseo1.find({...
.find
的结果是所有具有 User = Parse.User.current())
的对象和所有具有 Deseo = Artist<的对象/code> 但我希望将两个查询的对象放在一起:
The result of the .find
is all the objects with User = Parse.User.current())
and all the objects with Deseo = artist
but I want the objects with the two queries together:
User = Parse.User.current())
和 Deseo = 艺术家
推荐答案
您实际上已经正确设置了它以执行 AND 查询.问题(假设您的数据结构设置正确)是您的 User 字段是指向 User 表的指针.因此,您需要查询一个等于指针的用户,而不是一个等于 Parse.User.current() 的用户,后者将返回一个字符串.类似于以下内容:
You've actually got it setup correctly to do an AND query. The problem (assuming that your data structure is setup properly) is that your User field is a Pointer to the User table. Therefore, you need to query for a User equal to the pointer, as opposed to a User equal to Parse.User.current() which will return a string. Something like the following:
var userPointer = {
__type: 'Pointer',
className: 'User',
objectId: Parse.User.current().id
}
queryDeseo1.equalTo('User', userPointer);
相关文章