Comparing version 0.0.5 to 0.0.6
@@ -192,3 +192,9 @@ var EventEmitter = require('events').EventEmitter, | ||
self.isNew = false; | ||
if(fn) fn(err, docs); | ||
if(fn) { | ||
try { | ||
fn(err, docs); | ||
} catch (err) { | ||
console.error(err.stack || err); | ||
} | ||
} | ||
}); | ||
@@ -198,3 +204,9 @@ } else { | ||
self._dirty = {}; | ||
if(fn) fn(err, docs); | ||
if(fn) { | ||
try { | ||
fn(err, docs); | ||
} catch (err) { | ||
console.error(err.stack || err); | ||
} | ||
} | ||
}); | ||
@@ -214,6 +226,20 @@ } | ||
if (this.isNew){ | ||
if (fn) fn(); | ||
if (fn) { | ||
try { | ||
fn(); | ||
} catch (err) { | ||
console.error(err.stack || err); | ||
} | ||
} | ||
return this; | ||
} | ||
this._collection.remove({ _id: this._id }, fn || function(){}); | ||
this._collection.remove({ _id: this._id }, function(){ | ||
if (fn) { | ||
try { | ||
fn(); | ||
} catch (err) { | ||
console.error(err.stack || err); | ||
} | ||
} | ||
}); | ||
return this; | ||
@@ -378,2 +404,2 @@ }, | ||
})(); | ||
})(); |
{ "name": "mongoose" | ||
, "description": "ORM for MongoDB" | ||
, "version": "0.0.5" | ||
, "version": "0.0.6" | ||
, "author": "LearnBoost <dev@learnboost.com>" | ||
@@ -5,0 +5,0 @@ , "dependencies": { "mongodb": "0.7.9"} |
@@ -143,3 +143,3 @@ require.paths.unshift('.') | ||
User.find({}).all(function(docs){ | ||
assert.ok(!john.isNew); | ||
assert.ok(!john.isNew); | ||
assert.ok(docs.length == 1); | ||
@@ -170,4 +170,40 @@ john.remove(function(){ | ||
}); | ||
}, | ||
"thrown exceptions don't re-execute callbacks on save": function(){ | ||
var db = mongoose.test() | ||
, User = db.model('User') | ||
, count = 0 | ||
var john = new User(); | ||
john.first = 'John'; | ||
john.last = 'Locke'; | ||
john.save(function(){ | ||
++count; | ||
assert.equal(1, count); | ||
setTimeout(function(){ db.terminate() }, 100); | ||
throw new Error("made a boo boo"); | ||
}); | ||
}, | ||
"thrown exceptions don't re-execute callbacks on remove": function(){ | ||
var db = mongoose.test() | ||
, User = db.model('User') | ||
, count = 0 | ||
var john = new User(); | ||
john.first = 'John'; | ||
john.last = 'Locke'; | ||
john.save(function(){ | ||
john.remove(function(){ | ||
++count; | ||
assert.equal(1, count); | ||
setTimeout(function(){ db.terminate() }, 100); | ||
throw new Error("made a boo boo"); | ||
}); | ||
}); | ||
} | ||
}; | ||
}; |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
400340
52
7711
6