Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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();
});
});
});
})
});
@shebbys

This comment has been minimized.

Copy link

shebbys commented Sep 23, 2011

When I execute this I get the options logged:

A.find({ square: 'hi' }, function (err, docs) { console.log(docs); });
{ options: { populate: {} },
safe: undefined,
_conditions: {},
op: 'find',
model: { [Function: model] modelName: 'A' } }
[]
A.find({ }, function (err, docs) { console.log(docs); });
{ options: { populate: {} },
safe: undefined,
_conditions: {},
op: 'find',
model: { [Function: model] modelName: 'A' } }
[]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.