Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
MongoDB Fundamentals

You're reading from  MongoDB Fundamentals

Product type Book
Published in Dec 2020
Publisher Packt
ISBN-13 9781839210648
Pages 748 pages
Edition 1st Edition
Languages
Concepts
Authors (4):
Amit Phaltankar Amit Phaltankar
Profile icon Amit Phaltankar
Juned Ahsan Juned Ahsan
Profile icon Juned Ahsan
Michael Harrison Michael Harrison
Profile icon Michael Harrison
Liviu Nedov Liviu Nedov
Profile icon Liviu Nedov
View More author details

Table of Contents (15) Chapters

Preface
1. Introduction to MongoDB 2. Documents and Data Types 3. Servers and Clients 4. Querying Documents 5. Inserting, Updating, and Deleting Documents 6. Updating with Aggregation Pipelines and Arrays 7. Data Aggregation 8. Coding JavaScript in MongoDB 9. Performance 10. Replication 11. Backup and Restore in MongoDB 12. Data Visualization 13. MongoDB Case Study Appendix

Query Arrays and Nested Documents

In Chapter 2, Documents and Data Types, we learned that MongoDB documents support complex object structures such as arrays, nested objects, arrays of objects, and more. The arrays and nested documents help store self-contained information. It is extremely important to have a mechanism to easily search for and retrieve the information stored in such complex structures. The MongoDB query language allows us to query such complex structures in the most intuitive manner. First, we will learn how to run queries on the array elements, and then we will learn how to run them on nested object fields.

Finding an Array by an Element

Querying over an array is similar to querying any other field. In the movies collection, there are several arrays, and the cast field is one of them. Consider that, in your movies service, the user wants to find movies starring the actor Charles Chaplin. To create the query for this search, use an equality check on the field...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}