MongoDBコレクション: MongoDBコレクション内のすべてのドキュメントの単一フィールドを選択する方法


db.inventory.find( { type: 'food' }, { item: 1, qty: 1 } )
Mongoの人々からの上記の例では、返されたドキュメントはアイテム、QTYとCHERIDのフィールドだけを含みます.
db.inventory.find( { type: 'food' }, { item: 1, qty: 0 } )
Mongoの人々からの上記の例では、返されたドキュメントは項目のフィールドだけを含んでいます.
参考文献
  • https://stackoverflow.com/questions/25589113/how-to-select-a-single-field-for-all-documents-in-a-mongodb-collection
  • https://stackoverflow.com/questions/25589113/how-to-select-a-single-field-for-all-documents-in-a-mongodb-collection