Created
August 24, 2011 12:07
-
-
Save aheckmann/1167922 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose') | |
var Schema = mongoose.Schema | |
console.error('mongoose version %s', mongoose.version); | |
var s = new Schema({ name: String }) | |
s.pre('init', function (next, doc) { | |
console.error('pre', arguments); | |
var changed = { name: doc.first + ' ' + doc.last }; | |
next(changed); | |
}); | |
var P = mongoose.model('Person', s); | |
var p = new P; | |
p.init({ first: 'aaron', last: 'heckmann'}); | |
console.error('p is %j', p); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment