Permalink
Browse files

added debug() calls to query.js

  • Loading branch information...
1 parent a13e754 commit 3fdfd9db9f8c15fae7f071dd9b0bec1e0ffa55bc @tj tj committed Apr 4, 2012
Showing with 7 additions and 0 deletions.
  1. +7 −0 lib/query.js
View
7 lib/query.js
@@ -9,6 +9,7 @@ var utils = require('./utils')
, inGroupsOf = utils.inGroupsOf
, tick = utils.tick
, QueryStream = require('./querystream')
+ , debug = require('debug')('mongoose:query');
/**
* Query constructor
@@ -904,6 +905,8 @@ Query.prototype.execFind = function (callback) {
var fields = utils.clone(options.fields = this._fields);
+ debug('.find(%j, %j)', castQuery, options);
+
model.collection.find(castQuery, options, function (err, cursor) {
if (err) return promise.error(err);
cursor.toArray(tick(cb));
@@ -1073,6 +1076,8 @@ Query.prototype.findOne = function (callback) {
var fields = utils.clone(options.fields = this._fields);
+ debug('.findOne(%j, %j)', castQuery, options);
+
model.collection.findOne(castQuery, options, tick(function (err, doc) {
if (err) return promise.error(err);
if (!doc) return promise.complete(null);
@@ -1221,6 +1226,7 @@ Query.prototype.update = function update (doc, callback) {
}
if (castDoc) {
+ debug('.update(%j, %j, %j)', castQuery, castDoc, options);
model.collection.update(castQuery, castDoc, options, tick(callback));
} else {
process.nextTick(function () {
@@ -1454,6 +1460,7 @@ Query.prototype.remove = function (callback) {
}
var castQuery = this._conditions;
+ debug('.remove(%j, %j)', castQuery, options);
model.collection.remove(castQuery, options, tick(callback));
return this;
};

0 comments on commit 3fdfd9d

Please sign in to comment.