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
You can use dot notation to reference sub-document fields
var doc = db.collection_name.find({"metadata.id":{$exists:true}})