All operations use the executor

pull/2/head
Louis Chatriot 12 years ago
parent f260b8a854
commit 7469b0d442
  1. 14
      lib/datastore.js

@ -425,7 +425,7 @@ Datastore.prototype.insert = function () {
* Find all documents matching the query
* @param {Object} query MongoDB-style query
*/
Datastore.prototype.find = function (query, callback) {
Datastore.prototype._find = function (query, callback) {
var res = []
, self = this
, candidates = this.getCandidates(query)
@ -445,12 +445,16 @@ Datastore.prototype.find = function (query, callback) {
return callback(null, res);
};
Datastore.prototype.find = function () {
this.executor.push({ this: this, fn: this._find, arguments: arguments });
};
/**
* Find one document matching the query
* @param {Object} query MongoDB-style query
*/
Datastore.prototype.findOne = function (query, callback) {
Datastore.prototype._findOne = function (query, callback) {
var self = this
, candidates = this.getCandidates(query)
, i
@ -469,6 +473,10 @@ Datastore.prototype.findOne = function (query, callback) {
return callback(null, null);
};
Datastore.prototype.findOne = function () {
this.executor.push({ this: this, fn: this._findOne, arguments: arguments });
};
/**
* Update all docs matching query
@ -501,7 +509,7 @@ Datastore.prototype._update = function (query, updateQuery, options, cb) {
function (cb) { // If upsert option is set, check whether we need to insert the doc
if (!upsert) { return cb(); }
self.findOne(query, function (err, doc) {
self._findOne(query, function (err, doc) {
if (err) { return callback(err); }
if (doc) {
return cb();

Loading…
Cancel
Save