javascript - retrieve unique values for key from parse.com when class has > 1000 objects -
in parse have class named "testscore". each object has key named "quizname".
i need array of unique "quizname" values. wrote below queries "testclass" , loops through results looking unique "quizname" values.
at first seemed job. realized maximum number of returned objects 1000. there more 1000 objects stored means method not guarantee end values.
function loadtests(){ //create array hold each unique test name find them var uniqueentries = []; //query parse homecoming testscore objects var testscore = parse.object.extend("testscore"); var query = new parse.query(testscore); query.limit(1000) //added after realizing default query limit 100 query.find({ success: function(testscore) { $(testscore).each(function(index, score) { //here loop though of returned objects looking @ "quizname" each if($.inarray(score.get("quizname"), uniqueentries) === -1) { //if quiz name not in "uniqueentries" array, add together array uniqueentries.push(score.get("quizname")); } }); //do stuff quiznames here...., add together them options in select boxes } }); }
i looked @ {parse.query} notcontainedin(key, values) looks promising cant figure out if can add together values array find them. seems have have array start (defeating whole point.)
this part of docs "{parse.query} returns query, can chain call." makes me think might able chain queries need, doesn't seem efficient.
how can retrieve unique values key "quizname" when class has > 1000 objects?
i'm sure you're long past now, way know of utilize 1 query after using .skip(#) value each query. 1000, query 1 time again .skip(1000), concatenate items first list , second, query 1 time again .skip(2000), etc...
be aware think there's limit on skip values of 10,000. don't take word on that, pointing think right should confirm if think applies situation.
javascript parse.com
No comments:
Post a Comment