Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

feature(monk): pass options to monk .find() calls #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,14 @@ function getStorage(db, zone) {
all: function(cb) {
return table.find({}, cb);
},
find: function(data, cb) {
return table.find(data, cb);
find: function(data, opts, cb) {
// keep things backwards compatible with the previous API signature
// where the consumer only passes query data and a callback
if (typeof opts === 'function') {
return table.find(data, opts);
}

return table.find(data, opts, cb);
},
delete: function(id, cb) {
return table.findOneAndDelete({id: id}, cb);
Expand Down
13 changes: 13 additions & 0 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,18 @@ describe('Mongo', function() {
collectionObj.findOneAndDelete.should.be.calledWith({id: 'walterwhite'}, cb);
});
});

describe(method + '.find', function() {
it('should pass options to find', function() {
var cb = sinon.stub(),
options = {
limit: 1
};


Storage(config)[method].find({}, options, cb);
collectionObj.find.should.be.calledwith({}, options, cb);
});
});
});
});