1

我想在使用mongoskinrunCommandmongoDB中使用。目前我正在做这样的事情:

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"})

任何人都可以帮助我或任何替代方案,谢谢!

4

1 回答 1

1

Use db.command().

db.command( { distinct: "powders", key: "color" }, function( err, result ) {
    // ...
});
于 2014-08-24T11:01:31.967 回答