解析我有一个名为“TestScore”的类。每个对象都有一个名为“quizName”的键。当类具有> 1000个对象时,从parse.com检索密钥的唯一值
我需要得到一个唯一的“quizName”值的数组。我写了下面的代码来查询“TestClass”并遍历结果寻找唯一的“quizName”值。
起初似乎做的工作。但后来我意识到返回对象的最大数量是1000.很快就会有超过1000个对象存储,这意味着这种方法并不能保证我最终会得到所有的值。
function loadTests(){
//create an array to hold each unique test name as we find them
var uniqueEntries = [];
//query parse to return TestScore objects
var TestScore = Parse.Object.extend("TestScore");
var query = new Parse.Query(TestScore);
query.limit(1000) //added this after realizing that the default query limit is only 100
query.find({
success: function(testScore) {
$(testScore).each(function(index, score) {
//here I loop though all of the returned objects looking at the "quizName" for each
if($.inArray(score.get("quizName"), uniqueEntries) === -1) {
//if the quiz name is not already in the "uniqueEntries" array, I add it to the array
uniqueEntries.push(score.get("quizName"));
}
});
//do stuff with quiznames here...., add them as options in select boxes mostly
}
});
}
我看着{Parse.Query} notContainedIn(key, values)这看起来很有希望,但无法弄清楚,如果我找到他们,我可以将值添加到阵列。看起来我必须有一个数组来开始(击败整个点)。
文档的这一部分“{Parse.Query}返回查询,因此您可以链接此调用。”让我觉得我可以将查询链接在一起以获得我需要的内容,但这看起来效率不高。
当我的班级拥有> 1000个对象时,如何检索关键“quizName”的唯一值?
你好比尔,感谢您的答复。这实际上是我在随机博客文章的帮助下完成的确切方法。我忘记了这个问题。我在这里发布了我的最终代码,以便将来可以帮助其他人。而且,你也可以将它限制在10000跳过限制上,但是能够排除内置结果,这对我目前的使用来说不是问题。 – DelightedD0D 2015-02-21 09:28:40