Created
December 8, 2011 22:41
-
-
Save aheckmann/1449032 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'); | |
mongoose.connect('localhost', 'test'); | |
mongoose.set('debug', true) | |
var Foo = new mongoose.Schema({ | |
name: { type: String | |
, index: { unique: true, background: true } | |
} | |
}, { collection: 'a'}); | |
var A = mongoose.model('a', Foo); | |
mongoose.connection.on('error', function (err) { | |
// will show the index error | |
console.log('connection err', err); | |
}) | |
mongoose.connection.on('open', function () { | |
console.log('running query...'); | |
A.find().run(function (err, docs) { | |
console.log('\nquery error? %s', !! err, err && err.stack || '') | |
// returns 101 docs instead of all in the collection | |
console.log('returned %d docs', docs && docs.length || 0) | |
mongoose.disconnect(); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment