Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node mongodb native 我想在使用mongoskin的同时在mongoDB中使用runCommand_Node Mongodb Native_Mongoskin - Fatal编程技术网

Node mongodb native 我想在使用mongoskin的同时在mongoDB中使用runCommand

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

我想在使用时在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.find()
但是我需要一个函数来完成这个任务

db.runCommand({distinct: "powders", key: "color"})
有人能帮我解决这个问题吗, 谢谢

使用


我可以用这个回调函数吗?
db.command( { distinct: "powders", key: "color" }, function( err, result ) {
    // ...
});