Finding all records containing a given subfield in mongodb

前端 未结 1 1107
既然无缘
既然无缘 2021-01-01 16:08

In mongodb, i can find all those records in a collection in database db that contain a particular field using the following query

var doc = db.collection_na         


        
相关标签:
1条回答
  • 2021-01-01 16:46

    You can use dot notation to reference sub-document fields

    var doc = db.collection_name.find({"metadata.id":{$exists:true}})
    
    0 讨论(0)
提交回复
热议问题