HMdeveloper
HMdeveloper

Reputation: 2884

equivalent of limit with to parameter in mongodb

I have a mysql query as follow:

select * from table limit 3,100

But I do not really know how to convert it to mongo, for example if the 3 was not in the query it was easy to do that like as follow:

db.userdetails.find().limit(2)

but with limit 3,100 I do not really know how to do it, Is it possible to do this in mongo at all?

Upvotes: 0

Views: 488

Answers (1)

ccheneson
ccheneson

Reputation: 49410

Try

db.userdetails.find().skip(3).limit(100)

This will skip the first 3 elements of the result set and take the 100 following elements

Upvotes: 2

Related Questions