Created
September 23, 2011 17:11
-
-
Save aheckmann/1237913 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', 'testing_535'); | |
console.error('mongoose version', mongoose.version); | |
var OID = mongoose.Types.ObjectId; | |
var ASchema = new mongoose.Schema({ | |
square: mongoose.Schema.ObjectId | |
, task: Number | |
}); | |
var A = mongoose.model('A', ASchema); | |
mongoose.connection.on('open', function () { | |
var id = new OID; | |
A.create( | |
{ square: id, task: 1 } | |
, { square: new OID, task: 1 } | |
, { square: new OID, task: 1 } | |
, { square: new OID, task: 1 } | |
, { square: new OID, task: 1 } | |
, { square: new OID, task: 1 } | |
, { square: new OID, task: 1 } | |
, { square: new OID, task: 1 } | |
, { square: new OID, task: 1 } | |
, { square: new OID, task: 1 } | |
, { square: new OID, task: 1 } | |
, { square: new OID, task: 1 } | |
, { square: new OID, task: 1 } | |
, { square: new OID, task: 1 }, function (err) { | |
if (err) return console.error(err.stack||err); | |
A.find({}, function (err, docs) { | |
if (err) return console.error(err.stack||err); | |
console.error(docs); | |
console.error('next'); | |
var ids = id.toString(); | |
A.find({ square: ids }, function (err, docs) { | |
if (err) return console.error(err.stack||err); | |
console.error('found by id'); | |
console.error(docs); | |
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
When I execute this I get the options logged: