Comparing version 0.2.2 to 0.2.3
43
index.js
@@ -22,23 +22,2 @@ var mongo = require('mongodb'); | ||
}(); | ||
var normalize = function() { | ||
var longify = function(val) { | ||
if (!val || typeof val !== 'object') { | ||
return val; | ||
} | ||
for (var i in val) { | ||
if (Object.prototype.toString.call(val[i]) === '[object Long]') {$ | ||
val[i] = parseInt(val[i], 10); | ||
} else if (i !== '_id' && typeof val[i] === 'object') { | ||
val[i] = longify(val[i]); | ||
} | ||
} | ||
return val; | ||
}; | ||
return function(callback) { | ||
return function(err, val) { | ||
callback(err, longify(val)); | ||
}; | ||
}; | ||
}(); | ||
var parse = function(options) { | ||
@@ -65,3 +44,3 @@ if (typeof options === 'object') { | ||
Cursor.prototype.toArray = function(callback) { | ||
Cursor.prototype.toArray = function() { | ||
this._exec('toArray', arguments); | ||
@@ -100,7 +79,4 @@ }; | ||
Cursor.prototype._exec = function(name, args) { | ||
var callback = noop; | ||
var callback = typeof args[args.length-1] === 'function' ? args[args.length-1] : noop; | ||
if (typeof args[args.length-1] === 'function') { | ||
callback = args[args.length-1] = normalize(args[args.length-1]); | ||
} | ||
this._oncursor.get(common.fork(callback, function(cur) { | ||
@@ -126,3 +102,3 @@ cur[name].apply(cur, args); | ||
oncursor.get(common.fork(callback, function(cur) { | ||
cur.toArray(normalize(callback)); | ||
cur.toArray(callback); | ||
})); | ||
@@ -160,13 +136,10 @@ } | ||
}; | ||
Collection.prototype.remove = function() { | ||
this._exec('remove', arguments.length === 0 ? [{}] : arguments); // driver has a small issue with zero-arguments in remove | ||
}; | ||
Collection.prototype._exec = function(name, args) { | ||
var args = normalizeId(args); | ||
var callback = args[args.length-1]; | ||
var callback = typeof args[args.length-1] === 'function' ? args[args.length-1] : noop; | ||
if (typeof callback === 'function') { | ||
args[args.length-1] = callback = normalize(callback); | ||
} else { | ||
callback = noop; | ||
} | ||
this._oncollection.get(common.fork(callback, function(col) { | ||
@@ -177,3 +150,3 @@ col[name].apply(col, args); | ||
Object.keys(mongo.Collection.prototype).forEach(function(name) { | ||
Object.keys(mongo.Collection.prototype).forEach(function(name) { // we just wanna proxy any remaining methods on collections | ||
if (!Collection.prototype[name] && typeof mongo.Collection.prototype[name] === 'function') { | ||
@@ -180,0 +153,0 @@ Collection.prototype[name] = function() { |
@@ -5,3 +5,3 @@ { | ||
"keywords": ["mongo", "db", "mongodb"], | ||
"version":"0.2.2", | ||
"version":"0.2.3", | ||
"homepage" : "https://github.com/gett/mongojs", | ||
@@ -8,0 +8,0 @@ "author": "Ge.tt <hello@ge.tt>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4
8376
211