Reputation: 333
I have the following query where the oids
is an array of object id's.
users.find({ _id: { $in: oids } }, function(err, result){
console.log(result);
});
I expect a list of users where the id from the users are in the array of object id's, but the actual result looks like this:
{ db:
{ databaseName: 'users',
serverConfig:
{ _callBackStore: [Object],
host: 'localhost',
port: 27017,
options: [Object],
internalMaster: true,
connected: true,
poolSize: 5,
disableDriverBSONSizeCheck: false,
slaveOk: undefined,
_used: true,
replicasetInstance: null,
ssl: false,
sslValidate: false,
sslCA: null,
sslCert: undefined,
sslKey: undefined,
sslPass: undefined,
_readPreference: null,
socketOptions: [Object],
logger: [Object],
eventHandlers: [Object],
_serverState: 'connected',
_state: [Object],
recordQueryStats: false,
db: [Circular],
dbInstances: [Object],
connectionPool: [Object],
isMasterDoc: [Object] },
options: { w: 1 },
_applicationClosed: false,
native_parser: undefined,
bsonLib:
{ Code: [Function: Code],
Symbol: [Function: Symbol],
BSON: [Object],
DBRef: [Function: DBRef],
Binary: [Object],
ObjectID: [Object],
Long: [Object],
Timestamp: [Object],
Double: [Function: Double],
MinKey: [Function: MinKey],
MaxKey: [Function: MaxKey] },
bson: {}
... and so on ...
If I use user.findOne(...)
the result is the expected user, but I like to query all users in the array.
Upvotes: 2
Views: 1261
Reputation: 3366
find() method returns you a cursor, so 'result' is printing all the cursor details. I guess you have to do something like:
collection.find().toArray(function(err, results) {
test.assertEquals(1, results.length);
});
Upvotes: 1