Permalink
Browse files

Initial commit of plugin

  • Loading branch information...
1 parent 1bb4922 commit 9988e0e0cd38040eb048e9c374f44b6b78643360 @spatical spatical committed May 7, 2012
Showing with 25 additions and 1 deletion.
  1. +2 −1 .gitignore
  2. +23 −0 index.js
View
3 .gitignore
@@ -6,10 +6,11 @@ lib-cov
*.out
*.pid
*.gz
+*.project
pids
logs
results
node_modules
-npm-debug.log
+npm-debug.log
View
23 index.js
@@ -0,0 +1,23 @@
+"use strict";
+
+// lastMod.js
+module.exports = exports = function createdModifiedPlugin (schema, options) {
+ schema.add({
+ created: {
+ type: Date,
+ 'default': Date.now
+ }, modified: {
+ type: Date
+ }
+ });
+
+ schema.pre('save', function (next) {
+ this.modified = new Date;
+ next();
+ })
+
+ if (options && options.index) {
+ schema.path('created').index(options.index);
+ schema.path('modified').index(options.index);
+ }
+}

0 comments on commit 9988e0e

Please sign in to comment.