Skip to content
Browse files

Made pre save hooks in useTimestamps more robust with next(). Version…

… bump to 1.0.1.
  • Loading branch information...
1 parent 3563b7f commit a20aa4dd9ad75cb20ca6f54ff85d273d2ee3d9ed @bnoguchi bnoguchi committed Feb 3, 2011
Showing with 6 additions and 4 deletions.
  1. +4 −2 lib/plugins/useTimestamps.js
  2. +2 −2 package.json
View
6 lib/plugins/useTimestamps.js
@@ -13,24 +13,26 @@ exports.useTimestamps = function (schema, options) {
var unixtime = BinaryParser.decodeInt(this._id.id.slice(0, 4), 32, true, true);
return this._createdAt = new Date(unixtime * 1000);
});
- schema.pre('save', function () {
+ schema.pre('save', function (next) {
if (this.isNew) {
this.updatedAt = this.createdAt;
} else {
this.updatedAt = new Date;
}
+ next();
});
} else {
schema.add({
createdAt: Date
, updatedAt: Date
});
- schema.pre('save', function () {
+ schema.pre('save', function (next) {
if (!this.createdAt) {
this.createdAt = this.updatedAt = new Date;
} else {
this.updatedAt = new Date;
}
+ next();
});
}
};
View
4 package.json
@@ -1,8 +1,8 @@
{ "name": "mongoose-types"
, "description": "More types for mongoose"
-, "version": "1.0.0"
+, "version": "1.0.1"
, "author": "Brian Noguchi"
-, "dependencies": { "mongoose": "1.0.0"}
+, "dependencies": { "mongoose": ">= 1.0.0"}
, "keywords": [ "mongoose", "mongo", "mongodb", "types" ]
, "scripts": { "test": "make test" }
, "engines": { "node": ">= 0.1.101" }

0 comments on commit a20aa4d

Please sign in to comment.
Something went wrong with that request. Please try again.