I'm learning MongoDB and trying to retrieve objects by a specific key value using MongoDB client.
I have this data:
{ "type": "products", "products": { "Intel® Core™ i9-9980XE Extreme Edition": { "description": null, "price": 2457, "catalog_id": "1" }, "Intel® Core™ i9-9980HK": { "description": null, "price": 1548, "catalog_id": "1" }, "AMD Ryzen Threadripper 2990WX": { "description": null, "price": 500, "catalog_id": "2" }, "Baikalel Ectronics BE-M1000": { "description": null, "price": 128, "catalog_id": "3" }, "GeForce RTX 2080 Ti": { "description": null, "price": 2048, "catalog_id": "5" } } } I've find out how to access to data in nested objects:
db.shop.findOne( { type : "products" }).products["GeForce RTX 2080 Ti"].price But I'm a little bit confused how to get all hested objects filtred by "catalog_id": "1"
When I use
db.shop.find( { type : "products" }, {"catalog_id": "1"}) MongoDB client shows only id of the main object.