
- MongoDB Tutorial
- MongoDB - Home
- MongoDB - Overview
- MongoDB - Advantages
- MongoDB - Environment
- MongoDB - Data Modeling
- MongoDB - Create Database
- MongoDB - Drop Database
- MongoDB - Create Collection
- MongoDB - Drop Collection
- MongoDB - Data Types
- MongoDB - Insert Document
- MongoDB - Query Document
- MongoDB - Update Document
- MongoDB - Delete Document
- MongoDB - Projection
- MongoDB - Limiting Records
- MongoDB - Sorting Records
- MongoDB - Indexing
- MongoDB - Aggregation
- MongoDB - Replication
- MongoDB - Sharding
- MongoDB - Create Backup
- MongoDB - Deployment
- MongoDB - Java
- MongoDB - PHP
- Advanced MongoDB
- MongoDB - Relationships
- MongoDB - Database References
- MongoDB - Covered Queries
- MongoDB - Analyzing Queries
- MongoDB - Atomic Operations
- MongoDB - Advanced Indexing
- MongoDB - Indexing Limitations
- MongoDB - ObjectId
- MongoDB - Map Reduce
- MongoDB - Text Search
- MongoDB - Regular Expression
- Working with Rockmongo
- MongoDB - GridFS
- MongoDB - Capped Collections
- Auto-Increment Sequence
- MongoDB Useful Resources
- MongoDB - Questions and Answers
- MongoDB - Quick Guide
- MongoDB - Useful Resources
- MongoDB - Discussion
Find inside a hash MongoDB?
To find inside a hash MongoDB, you can use dot(.) notation. Let us first create a collection with documents
> db.hashDemo.insertOne({"ClientName":"Larry","ClientAge":23,"ClientDetails":{ "isEducated": true, "ClientProject" : "University Management"}}); { "acknowledged" : true, "insertedId" : ObjectId("5ca1ef1266324ffac2a7dc5e") } > db.hashDemo.insertOne({"ClientName":"Chris","ClientAge":26,"ClientDetails":{ "isEducated":false, "ClientProject" : "Online Book Store"}}); { "acknowledged" : true, "insertedId" : ObjectId("5ca1ef7766324ffac2a7dc5f") }
Following is the query to display all documents from a collection with the help of find() method
> db.hashDemo.find().pretty();
This will produce the following output
{ "_id" : ObjectId("5ca1ef1266324ffac2a7dc5e"), "ClientName" : "Larry", "ClientAge" : 23, "ClientDetails" : { "isEducated" : true, "ClientProject" : "University Management" } } { "_id" : ObjectId("5ca1ef7766324ffac2a7dc5f"), "ClientName" : "Chris", "ClientAge" : 26, "ClientDetails" : { "isEducated" : false, "ClientProject" : "Online Book Store" } }
Following is the query to find inside a hash MongoDB
> db.hashDemo.find({"ClientDetails.isEducated" : false, "ClientDetails.ClientProject" : "Online Book Store"}).pretty();
This will produce the following output
{ "_id" : ObjectId("5ca1ef7766324ffac2a7dc5f"), "ClientName" : "Chris", "ClientAge" : 26, "ClientDetails" : { "isEducated" : false, "ClientProject" : "Online Book Store" } }
- Related Articles
- Find sum of fields inside array in MongoDB?
- Add MD5 hash value to MongoDB collection?
- How to perform $gt on a hash in a MongoDB document?
- Increment MongoDB value inside a nested array
- Get array items inside a MongoDB document?
- MongoDB query to find multiple matchings inside array of objects?
- Apply a condition inside subset in MongoDB Aggregation?
- MongoDB query to find data from an array inside an object?
- MongoDB Increment value inside nested array?
- MongoDB aggregation with equality inside array?
- How to remove duplicate values inside a list in MongoDB?
- How to find keys of a hash in JavaScript?
- Python program to find hash from a given tuple
- MongoDB Aggregation to slice array inside array
- Selecting database inside the JS in MongoDB?

Advertisements