問題描述
我需要用 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);
這篇關于如何制作 Parse.Query.AND?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!