Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Initial commit of plugin

  • Loading branch information...
commit 9988e0e0cd38040eb048e9c374f44b6b78643360 1 parent 1bb4922
Steven Hansen authored May 07, 2012

Showing 2 changed files with 25 additions and 1 deletion. Show diff stats Hide diff stats

  1. 3  .gitignore
  2. 23  index.js
3  .gitignore
@@ -6,10 +6,11 @@ lib-cov
6 6
 *.out
7 7
 *.pid
8 8
 *.gz
  9
+*.project
9 10
 
10 11
 pids
11 12
 logs
12 13
 results
13 14
 
14 15
 node_modules
15  
-npm-debug.log
  16
+npm-debug.log
23  index.js
... ...
@@ -0,0 +1,23 @@
  1
+"use strict";
  2
+
  3
+// lastMod.js
  4
+module.exports = exports = function createdModifiedPlugin (schema, options) {
  5
+  schema.add({ 
  6
+    created: {
  7
+      type: Date,
  8
+      'default': Date.now
  9
+    }, modified: {
  10
+      type: Date
  11
+    } 
  12
+  });
  13
+
  14
+  schema.pre('save', function (next) {
  15
+    this.modified = new Date;
  16
+    next();
  17
+  })
  18
+
  19
+  if (options && options.index) {
  20
+    schema.path('created').index(options.index);
  21
+    schema.path('modified').index(options.index);
  22
+  }
  23
+}

0 notes on commit 9988e0e

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