parse.com:id列的内部查询不检索我想要的所有列

时间:2015-07-16 12:00:26

标签: javascript parse-platform

解析类架构:

班级名称:余额

列:myid createdAt amount

班级名称:令牌

列:myid registerUser isActiveToken

我想使用parse.com javascript检索金额,myid,registerUser,isActiveToken。

我无法使用parse js refernce来获取它。

https://parse.com/docs/js/guide#queries

  

matchesKeyInQuery在解析js中给出了一个toJSOn错误

var balance = Parse.Object.extend("balance");
var teamQuery = new Parse.Query(balance);
var userQuery = new Parse.Query("tokens");
userQuery.matchesKeyInQuery("amount", teamQuery); //I made a blunder here by not understanding matchesKeyInQuery
userQuery.find({
    success: function(results) {
        // results has the list of users with a hometown team with a winning record
    }
});
  

matchesQuery抛出错误的内部查询错误

var balance = Parse.Object.extend("balance");
    var tokens = Parse.Object.extend("tokens");
    var innerQuery = new Parse.Query(balance);
    innerQuery.exists("amount");
    var query = new Parse.Query(tokens);
    query.matchesQuery("myid", innerQuery);
    query.find({
        success: function(comments) {
            // tokens now contains the tokens for balance with amounts.
        }
    });

通过javascript合并(肮脏的方式)克服了这个,很想在Parse SDK中找到一些东西

1 个答案:

答案 0 :(得分:0)

在第一个查询方法中matchesKeyInQuery接受3个参数,第一个是被调用查询中的键,第二个参数是传递查询中的键,第三个是传递的查询。

    var balance = Parse.Object.extend("balance");
    var tokens = Parse.Object.extend("tokens");
    var teamQuery = new Parse.Query(balance);
    var userQuery = new Parse.Query(tokens);
    userQuery.equalTo("myId",12); //sample
    userQuery.matchesKeyInQuery("myId","myId", teamQuery);
    userQuery.find({
        success: function(results) {
            // results has the list of users with a hometown team with a winning record
        }
    });

对于第二个查询,您应该在两个集合之间建立关系。并且您可以使用matchesQuery方法。