As my question suggest, I would like to limit the number of documents displayed when the find()
function is called on a collection like this:
exports.findAll = function(req, res) {
db.collection('temp', function(err, collection) {
collection.find().toArray(function(err, items) {
res.send(items);
});
});
};
The above code will display all the documents present in the temp collection. But is there a way where i could limit the number of documents being displayed to 10? And i would like to send the last ten documents(By last i mean, the ones added lately)
I would really appreciate any suggestions.
Thanks a lot in advance.