我有以下查询,其中oids
是对象 id 的数组。
users.find({ _id: { $in: oids } }, function(err, result){
console.log(result);
});
我希望用户的 id 位于对象 id 数组中的用户列表,但实际结果如下所示:
{ 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 ...
如果我使用user.findOne(...)
结果是预期的用户,但我喜欢查询数组中的所有用户。