2

I'm using GeddyJS framework for a NodeJS application.

I got stuck with a problem in setting limit while making a call to all() method in any model.

I tried providing limit as one of the option but its not working as expected.

geddy.model.User.all({userId: 1}, {sort:{createdAt: "desc"},limit:10}, function(err,data){

Any Help???

PS: We are using MongoDB as database.

2 Answers2

3

This is what you're looking for I think:

geddy.model.User.all(
  {}, 
  {sort: {createdAt: 'desc'}, limit: 10},
  function (err, data) {
    // do stuff
  }
);

If this isn't working for you, let us (the framework devs) know what error your getting.

Techwraith
  • 1,298
  • 1
  • 10
  • 12
2

I don't see anything in the docs about using limit; however, this might work for you.

geddy.model.User.all(
                     {userId: 1}, 
                     {sort:{createdAt: "desc"}},
                     {limit:10}, 
                     function(err, data){
                      // do stuff
                     })
thtsigma
  • 4,878
  • 2
  • 28
  • 29