我无法从结果中筛选出_id?

时间:2018-01-03 04:53:05

标签: mongodb mongodb-query

MongoDB数据库具有以下类型的数据:

{ _id: 5a4c5ffaeb092f0c1daac8b4, name: 'Jenny', age: 10 }

下面的代码也打印出_id

var url = 'mongodb://localhost:27017/learnyoumongo';
var mongo = require('mongodb').MongoClient;
mongo.connect(url, function(err, db) {
  if (err) throw err;
  // db gives access to the database
  const myDb = db.db('learnyoumongo');
  var parrots = myDb.collection('parrots');
  parrots.find({
    age: {
      $gt: parseInt(process.argv[2])
    }
  }, {
    name: 1,
    age: 1,
    _id: 0

  }).toArray(function(err, documents) {
    // Here is where we decide what to do with the query results
    if (err) throw err;
    console.log(documents);
    db.close();
  });
});

输出

{ _id: 5a4c5ffaeb092f0c1daac8b4, name: 'Jenny', age: 10 }

我不希望输出中有_id及其value

1 个答案:

答案 0 :(得分:1)

字段应定义为let arr: [NSUIColor] = [UIColor.red, UIColor.green, UIColor.yellow] lineChartDataSet.circleColors = arr 的一部分(请查看documentation)。

您的代码应如下所示:

options