Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MongoDB 3.2 Limit / Skip not working #27

Open
molywitman opened this issue Sep 8, 2016 · 1 comment
Open

MongoDB 3.2 Limit / Skip not working #27

molywitman opened this issue Sep 8, 2016 · 1 comment

Comments

@molywitman
Copy link

Hi,

moving to mongoDB 3.2.9 got problem with limit
https://github.com/florianholzapfel/express-restify-mongoose/issues/

to fix changed --
schema.method('getDescendants', function () {
var query = new Query(arguments);
var promise = new mongoose.Promise;
if (query.callback)
promise.addBack(query.callback);
var self = this;

    query.condition.path = {
        $regex: (self.path ? '' : '^') + options.separator + self._id.toString()
    };

    query.sort.path = 1;
    query.sort._w = query.sort._w || 1;
        query.sort._w = 1;

    var cursor = self.constructor.find(query.condition, query.fields)
    .sort(query.sort);
    if (query.limit)
        cursor.limit(parseInt(query.limit)); <------------------------------------------- changed
    if (query.skip)
        cursor.skip(query.skip);
    cursor.exec(function (err, data) {
        if (err)
            promise.error(err);
        else
            promise.complete(data);
    });
    return promise;
});
@joniba
Copy link

joniba commented Sep 22, 2016

Tried to reproduce this in a test with mongodb 3.2 without success. Although attempting to upgrade mongoose-materialized's mongoose library to the latest version caused most of the tests to fail. The above mentioned fix can be found in this fork. If there is more interest in this issue I can try to provide a reproducible sample.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants