Can specify 2 or 3 args and still get desired results

pull/2/head
Louis Chatriot 10 years ago
parent 4f2b2ac2dd
commit 75ee7a967f
  1. 17
      lib/datastore.js

@ -377,7 +377,20 @@ Datastore.prototype.count = function(query, callback) {
* If no callback is passed, we return the cursor so that user can limit, skip and finally exec * If no callback is passed, we return the cursor so that user can limit, skip and finally exec
* @param {Object} query MongoDB-style query * @param {Object} query MongoDB-style query
*/ */
Datastore.prototype.find = function (query, callback) { Datastore.prototype.find = function (query, projection, callback) {
switch (arguments.length) {
case 1:
projection = {};
// callback is undefined, will return a cursor
break;
case 2:
if (typeof projection === 'function') {
callback = projection;
projection = {};
}
break;
}
var cursor = new Cursor(this, query, function(err, docs, callback) { var cursor = new Cursor(this, query, function(err, docs, callback) {
var res = [], i; var res = [], i;
@ -547,4 +560,6 @@ Datastore.prototype.remove = function () {
module.exports = Datastore; module.exports = Datastore;

Loading…
Cancel
Save