Comparing version 1.1.2 to 1.1.3
1.1.3 / 2011-03-04 | ||
================== | ||
* Added Promise#resolve [aheckmann] | ||
* Fixed backward compatibility with nulls [aheckmann] | ||
* Changed; Query#{run,exec} return promises [aheckmann] | ||
1.1.2 / 2011-03-03 | ||
@@ -3,0 +10,0 @@ ================== |
@@ -117,3 +117,3 @@ | ||
if (!schema && obj[i].constructor == Object){ // assume nested object | ||
if (!schema && obj[i] && obj[i].constructor == Object){ // assume nested object | ||
doc[i] = {}; | ||
@@ -569,4 +569,7 @@ init(obj[i], doc[i], path + '.'); | ||
var self = this | ||
, args = arguments; | ||
, args = arguments | ||
, pres = this.pres[methodName]; | ||
if (!pres) return oldFn.apply(this, args); | ||
function error (err){ | ||
@@ -577,18 +580,15 @@ var lastArg = args[args.length-1]; | ||
} | ||
var pres = this.pres[methodName]; | ||
if (!pres) return oldFn.apply(this, args); | ||
var pres = this.pres[methodName] | ||
, chain = pres.serial.map(function (fn, i) { | ||
return function (err) { | ||
if (arguments.callee._hookCalled) return; | ||
var chain = pres.serial.map(function (fn, i) { | ||
return function (err) { | ||
if (arguments.callee._hookCalled) return; | ||
if (err instanceof Error) | ||
error(err); | ||
else | ||
fn.call(self, chain[i+1] || parallel); | ||
if (err instanceof Error) | ||
error(err); | ||
else | ||
fn.call(self, chain[i+1] || parallel); | ||
arguments.callee._hookCalled = true; | ||
}; | ||
}); | ||
arguments.callee._hookCalled = true; | ||
}; | ||
}); | ||
@@ -595,0 +595,0 @@ chain.length ? chain[0]() : parallel(); |
@@ -284,3 +284,3 @@ | ||
exports.version = '1.1.2'; | ||
exports.version = '1.1.3'; | ||
@@ -287,0 +287,0 @@ /** |
@@ -121,2 +121,17 @@ | ||
/** | ||
* Sugar for handling cases where you may be | ||
* resolving to either an error condition or a | ||
* success condition. | ||
* | ||
* @param {Error} optional error or null | ||
* @param {Object} value to complete the promise with | ||
* @api public | ||
*/ | ||
Promise.prototype.resolve = function (err, val) { | ||
if (err) return this.error(err); | ||
return this.complete(val); | ||
}; | ||
/** | ||
* Module exports. | ||
@@ -123,0 +138,0 @@ */ |
var utils = require('./utils') | ||
, merge = utils.merge | ||
, Promise = require('./promise') | ||
, inGroupsOf = utils.inGroupsOf; | ||
@@ -35,16 +36,23 @@ | ||
Query.prototype.exec = function (op, callback) { | ||
var args = arguments; | ||
if ('function' === typeof op) { | ||
callback = op; | ||
if (this.op === 'update') { | ||
return this[this.op](this._updateArg, callback); | ||
} | ||
return this[this.op](callback); | ||
var promise = new Promise(); | ||
switch (typeof op) { | ||
case 'function': | ||
callback = op; | ||
op = null; | ||
break; | ||
case 'string': | ||
this.op = op; | ||
break; | ||
} | ||
args = Array.prototype.slice.call(arguments, 1); | ||
this.op = op; | ||
if (op === 'update' && args.length === 1) { | ||
args.unshift(this._updateArg); | ||
if (callback) promise.addBack(callback); | ||
if ('update' == this.op) { | ||
this.update(this._updateArg, promise.resolve.bind(promise)); | ||
return promise; | ||
} | ||
this[op].apply(this, args); | ||
this[this.op](promise.resolve.bind(promise)); | ||
return promise; | ||
}; | ||
@@ -51,0 +59,0 @@ |
{ | ||
"name": "mongoose" | ||
, "description": "Mongoose MongoDB ORM" | ||
, "version": "1.1.2" | ||
, "version": "1.1.3" | ||
, "author": "Guillermo Rauch <guillermo@learnboost.com>" | ||
@@ -6,0 +6,0 @@ , "keywords": ["mongodb", "mongoose", "orm", "data", "datastore", "nosql"] |
@@ -1041,4 +1041,19 @@ | ||
'test backwards compatibility with previously existing null values in db': function () { | ||
var db = start() | ||
, BlogPostB = db.model('BlogPostB', collection) | ||
, post = new BlogPostB(); | ||
post.collection.insert({ meta: { visitors: 9898, a: null } }, {}, function (err, b) { | ||
should.strictEqual(err, null); | ||
BlogPostB.findOne({_id: b[0]._id}, function (err, found) { | ||
should.strictEqual(err, null); | ||
found.get('meta.visitors').valueOf().should.eql(9898); | ||
db.close(); | ||
}) | ||
}) | ||
} | ||
// IDIOMATIC SYNTAX TESTS | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
1425735
25382