Created
April 30, 2012 21:33
-
-
Save rgarcia/2562852 to your computer and use it in GitHub Desktop.
weird mongoose behavior
This file contains 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
step = require 'step' | |
mongoose = require 'mongoose' | |
Schema = mongoose.Schema | |
schemas = {} | |
schemas.Foobar = new Schema | |
name : { type: String, trim: true, required: true, unique: true } | |
connection = mongoose.createConnection 'mongodb://127.0.0.1:27017/sandbox' | |
models = {} | |
models.Foobar = connection.model 'Foobar', schemas.Foobar | |
foobar = new models.Foobar | |
name: 'FOOOOO' | |
step () -> | |
models.Foobar.find {}, this | |
, (err, docs) -> | |
console.log 'found docs', docs | |
console.log 'disconnecting' | |
mongoose.disconnect this | |
, (err) -> | |
throw err if err | |
console.log 'disconnected' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment