Created
June 27, 2012 17:26
-
-
Save aheckmann/3005551 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'); | |
console.error( | |
'\n===========' | |
, ' mongoose version: ' | |
, mongoose.version | |
, '========\n\n' | |
); | |
var Schema = mongoose.Schema; | |
mongoose.connect('localhost', 'testing_saveorder'); | |
mongoose.connection.on('error', function () { | |
console.error(arguments); | |
}); | |
var schema = new Schema({ | |
name: String | |
}); | |
schema.pre('save', function (next) { | |
console.error('pre save'); | |
next(); | |
}); | |
schema.post('save', function () { | |
console.error('post save'); | |
}); | |
var A = mongoose.model('A', schema); | |
mongoose.connection.on('open', function () { | |
var a = new A({ name: 'saveorder' }); | |
a.save(function (err, a) { | |
console.error('save callback'); | |
mongoose.connection.db.dropDatabase(function () { | |
mongoose.connection.close(); | |
}); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment