Search code examples
mongodbmongodb-querybson

Retrieve value from the document in Mongo DB


enter image description here

Query: when i give "third_party_site_id" value in the above script in result i want only st_site_id value ? How to write the script to get only st_site_id value ?


Solution

  • db.collection.find({'third_party_site_id.fieldName':'valueToCheck'}, {st_site_id:1})

    First part is find query. Second part is projection.

    I suggest you to refer documentation