How to select a single field for all documents in a MongoDB collection?

前端 未结 20 1285
执念已碎
执念已碎 2020-11-22 07:58

In my MongoDB, I have a student collection with 10 records having fields name and roll. One record of this collection is:

{
    \"         


        
20条回答
  •  鱼传尺愫
    2020-11-22 08:47

    Use the Query like this in the shell:

    1. Use database_name

    e.g: use database_name
    

    2. Which returns only assets particular field information when matched , _id:0 specifies not to display ID in the result

    db.collection_name.find( { "Search_Field": "value" }, 
                      { "Field_to_display": 1,_id:0 }  )
    

提交回复
热议问题