From 7edacff614c04d464f42035f5b395cf0c6d94c08 Mon Sep 17 00:00:00 2001 From: Benjamin Pannell Date: Fri, 11 Apr 2014 22:33:36 +0200 Subject: [PATCH] Allow limit, sort and skip conditions to be passed to find and findOne --- lib/Model.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Model.js b/lib/Model.js index c2475cc..a3a7706 100644 --- a/lib/Model.js +++ b/lib/Model.js @@ -370,7 +370,7 @@ Model.prototype.find = function (conditions, options, callback) { if (!_.isPlainObject(conditions)) conditions = this.downstreamID(conditions); this.toSource(conditions); - this.collection.find(conditions).toArray((function (err, results) { + this.collection.find(conditions, { limit: options.limit, sort: options.sort, skip: options.skip }).toArray((function (err, results) { if (err) { this.emit('error', err); return callback(err); @@ -418,7 +418,7 @@ Model.prototype.findOne = Model.prototype.get = function (conditions, options, c this.toSource(conditions); var fromDB = (function() { - this.collection.findOne(conditions, (function (err, results) { + this.collection.findOne(conditions, { limit: options.limit, sort: options.sort, skip: options.skip }, (function (err, results) { if (err) { this.emit('error', err); return callback(err);