Created
September 4, 2012 17:26
-
-
Save aheckmann/3623812 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; | |
var assert = require('assert') | |
console.log('\n==========='); | |
console.log(' mongoose version: %s', mongoose.version); | |
console.log('========\n\n'); | |
mongoose.connect('localhost', 'testing_fifo', { server: { poolSize: 1 }}); // change poolSize to > 1 | |
mongoose.connection.on('error', function () { | |
console.error('connection error', arguments); | |
}); | |
var schema = new Schema({ | |
name: String | |
}); | |
var A = mongoose.model('A', schema); | |
mongoose.connection.on('open', function () { | |
console.log('opened'); | |
mongoose.set('debug', true); | |
A.create({ name: 'fifo1' }, { name: 'fifo2' }, function (err) { | |
if (err) return done(err); | |
A.$where('for (var i = 0; i < 5000000; i++) {}; return true').exec(function (err) { | |
// this blocks other ops if poolSize of 1 | |
console.log('where returned'); | |
}); | |
A.find({}).exec(function (err, docs) { | |
// will wait for $where to complete | |
console.error(arguments); | |
done() | |
}) | |
}); | |
}); | |
function done (err) { | |
if (err) console.error(err.stack); | |
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