How can I make Parse.Query.AND?

倖福魔咒の 提交于 2019-12-31 01:45:08

问题


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({...

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()) and Deseo = artist


回答1:


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);


来源:https://stackoverflow.com/questions/23737609/how-can-i-make-parse-query-and

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!