简体   繁体   中英

Parse.Query returning fewer objects than the limit

I am trying to return a list of users from my User class. I have 101 users. I get 90 users back.

I know that Parse queries cap the data at 100 objects unless specified, so I should be getting at least 100. Why am I getting fewer than 100? Where are my stray 11?

Here's my code:

function avAuthTime_C(){
var query = new Parse.Query(Parse.User);
query.limit = 1000;
query.count({
success: function(number) {
    // There are number instances of MyClass.
    console.log("Total Instances: "+number);
},

error: function(error) {
    // error is an instance of Parse.Error.
    console.log("Parse error");
    }
});

I have heard that Parse is being phased out. We're building an app for a long term school project, and while we'll be working on it for a few months, we'll be done (and graduated!) by the time parse closes.

According to the following post , you should be able to use _limit and _skip, and it should function properly.

Example:

query.count({
    success: function(count) {
        var chunk = 100;
        var cycles = Math.ceil(count / chunk);

        for (i = 0; i < cycles; i++) {
            var _query = new Parse.Query("ClassName");
            _query.descending("createdAt");
            _query._limit = chunk;
            _query._skip = i * chunk;

            console.log("getting results " + _query.skip.toString() + " to " + (_query.skip + _query.limit).toString());

            _query.find({
                success: function(results) {
                    var template = $("#ClassNameTemplate").html();
                    var class_name_html = Mustache.to_html(template, {"ClassName": results});
                    $("#classNameTable").find("tbody").append(class_name_html);
                },
                error: function(error) {
                    console.log("error");
                    console.log(error);
                }
            });
        }
    },
    error: function(error) {
        console.log("error");
        console.log(error);
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM