Thursday, 15 May 2014

node.js - Mongoose: How to slice the entire query? -



node.js - Mongoose: How to slice the entire query? -

i'm looking way m documents out of particular query, starting @ nth document, without rendering entire collection @ exec() callback , splice array there. i'm aware of .limit(x) works fine , dandy 0 x, knowledge there no way select query start limiting number of documents, limit(10) starting 5.

i tried this:

model.find().sort({creationdate: -1}).where("_id").splice([5,10]).exec(function(err, data) { if(err) res.send(502, "error in db database"); res.send(data); });

but resulting info consists of entire collection. ideas on how accomplish this?

.skip looking for

model.find(...).sort(...).skip(5).limit(10).exec(....)

node.js mongodb mongoose

No comments:

Post a Comment