
- 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
Querying object's field array values in MongoDB?
Query object’s field array value using arrayFieldName along with value. Let us create a collection with documents −
> db.demo295.insertOne({"status":["Active","Inactive"]}); { "acknowledged" : true, "insertedId" : ObjectId("5e4d4ea65d93261e4bc9ea39") } > db.demo295.insertOne({"status":["Yes","No"]}); { "acknowledged" : true, "insertedId" : ObjectId("5e4d4eb15d93261e4bc9ea3a") }
Display all documents from a collection with the help of find() method −
> db.demo295.find().pretty();
This will produce the following output −
{ "_id" : ObjectId("5e4d4ea65d93261e4bc9ea39"), "status" : [ "Active", "Inactive" ] } { "_id" : ObjectId("5e4d4eb15d93261e4bc9ea3a"), "status" : [ "Yes", "No" ] }
Following is how to query object's field array values in MongoDB −
> db.demo295.find({status:"Inactive"});
This will produce the following output −
{ "_id" : ObjectId("5e4d4ea65d93261e4bc9ea39"), "status" : [ "Active", "Inactive" ] }
- Related Articles
- How to improve querying field in MongoDB?
- Querying internal array size in MongoDB?
- Querying array elements with MongoDB?
- Querying an array of arrays in MongoDB?
- Querying only the field name and display only the id in MongoDB?
- Querying array of Embedded Documents in MongoDB based on Range?
- Querying from part of object in an array with MongoDB
- Native Querying MongoDB inside array and get the count
- Fetch specific field values in MongoDB
- Reverse array field in MongoDB?
- Querying null value in MongoDB?
- Querying with MongoDB subelement?
- Can I utilize indexes when querying by MongoDB subdocument without known field names?
- How to compare field values in MongoDB?
- MongoDB slice array in populated field?

Advertisements