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

limit filter ignored #769

Closed
barocsi opened this issue Nov 22, 2015 · 2 comments
Closed

limit filter ignored #769

barocsi opened this issue Nov 22, 2015 · 2 comments

Comments

@barocsi
Copy link

barocsi commented Nov 22, 2015

For some reason my limit filter is ignored (using mongodb connector).
Using the loopback-sandbox git, adding

datasources.json:
"db": {
    "host": "localhost",
    "database": "test",
    "name": "db",
    "connector": "mongodb",
    "debug":true
  },

adding a post model, exposing a remote method for testing

module.exports = function (Post) {

  Post.getNext = function (limit, cb) {
    var context = loopback.getCurrentContext();
    var http = context.get('http');
    var user = context.get('currentUser');
    console.log(limit)
    Post.find({
                  limit: 1
              }, cb);
  };

  Post.remoteMethod(
    'getNext',
    {
      accepts: [{arg: 'limit', type: 'string', required: false},
      ],
      returns: {arg: 'post', type: 'object'},
      http: {path: '/getNext', verb: 'get'}
    }
  );
}

the result ignores limit parameter and returns all items, always, even if hardcoded as in the example.
I am not sure where it went wrong or what would override it.
I am not able to debug since the debug flag has no effect at all as noted in #768

@barocsi
Copy link
Author

barocsi commented Nov 22, 2015

https://docs.strongloop.com/display/public/LB/Model+definition+JSON+file#ModeldefinitionJSONfile-Scopes

I have defined a default scope with limit. It was not clear for me, that the default scope is always active when defined and cannot be overridden.

@barocsi barocsi closed this as completed Nov 22, 2015
@0ff
Copy link

0ff commented Dec 8, 2015

In fact I think this was not intended and I've just submitted PR #787 to change that :-)

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