【发布时间】:2017-05-28 01:56:58
【问题描述】:
我在 shell 中成功运行了这个查询:
db.hourlydatas.find({'timeseries':ObjectId('1234')})
尝试将其翻译成 mongo 驱动程序:
MongoClient.connect(config.db, function(err, db) {
// Use the admin database for the operation
var collection = db.collection('hourlydatas');
collection.find({'timeseries':'1234'}).toArray(function(err, docs) {
// assert.equal(err, null);
console.log("Found the following records");
console.log(docs);
// callback(docs);
});
});
这不会返回任何文档,我假设是因为我没有将字符串转换为 objectID。这在驱动程序中可能吗?
【问题讨论】: