如何在 mongo shell 脚本中打印/使用键的特定值?

问题描述 投票:0回答:0

我正在从 shell 运行以下命令;

const records = db.issues.find().limit(1);

print('Record:', records);
print('ID:', records.id);

返回一条记录;

Record: [
  {
    _id: ObjectId("63f94e684902f564f7d418ca"),
    id: 1,
    status: 'New',
    owner: 'Ravan',
    effort: 5,
    created: ISODate("2019-01-15T00:00:00.000Z"),
    due: null,
    title: 'Error in console when clicking Add',
    description: 'Steps to recreate the problem:\n'
  }
]

所以我认为最后一行会产生;

ID: 1

它只是产生ID:,没有错误,我错过了什么?

下一个问题是,如果返回多条记录,我如何遍历游标?

干杯 C.

node.js mongodb mongo-shell
© www.soinside.com 2019 - 2024. All rights reserved.