From 146ec9d1f90299915332b9e34e65f7f39a9dbb56 Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Mon, 1 Oct 2012 10:10:53 -0700 Subject: [PATCH] fixed; debug output for Dates/ObjectId properties closes #1129 --- lib/drivers/node-mongodb-native/collection.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/drivers/node-mongodb-native/collection.js b/lib/drivers/node-mongodb-native/collection.js index 97458e47f53..a53857f9c2e 100644 --- a/lib/drivers/node-mongodb-native/collection.js +++ b/lib/drivers/node-mongodb-native/collection.js @@ -169,11 +169,15 @@ function format (obj, sub) { } else if ('Object' === x[key].constructor.name) { x[key] = format(x[key], true); } else if ('ObjectID' === x[key].constructor.name) { - var representation = 'ObjectId("' + x[key].toHexString() + '")'; - x[key] = { inspect: function() { return representation; } }; + ;(function(x){ + var representation = 'ObjectId("' + x[key].toHexString() + '")'; + x[key] = { inspect: function() { return representation; } }; + })(x) } else if ('Date' === x[key].constructor.name) { - var representation = 'new Date("' + x[key].toUTCString() + '")'; - x[key] = { inspect: function() { return representation; } }; + ;(function(x){ + var representation = 'new Date("' + x[key].toUTCString() + '")'; + x[key] = { inspect: function() { return representation; } }; + })(x) } else if (Array.isArray(x[key])) { x[key] = x[key].map(function (o) { return format(o, true)