Node mongodb native 我想在使用mongoskin的同时在mongoDB中使用runCommand
我想在使用时在mongoDB中使用。 目前我正在做这样的事情:Node mongodb native 我想在使用mongoskin的同时在mongoDB中使用runCommand,node-mongodb-native,mongoskin,Node Mongodb Native,Mongoskin,我想在使用时在mongoDB中使用。 目前我正在做这样的事情: app.get('/api/powders', function(req, res, next) { db.collection('powders').find({} ,{limit:0, sort: [['_id',-1]]}).toArray(function(e, results){ if (e) return next(e) res.send(results) }) }) 等于 db.powders
app.get('/api/powders', function(req, res, next) {
db.collection('powders').find({} ,{limit:0, sort: [['_id',-1]]}).toArray(function(e, results){
if (e) return next(e)
res.send(results)
})
})
等于
db.powders.find()
但是我需要一个函数来完成这个任务
db.runCommand({distinct: "powders", key: "color"})
有人能帮我解决这个问题吗,
谢谢 使用
我可以用这个回调函数吗?
db.command( { distinct: "powders", key: "color" }, function( err, result ) {
// ...
});