4. Querying Documents

Overview

This chapter discusses how to prepare and execute queries in MongoDB. You will learn how to find documents from a collection and limit the fields shown in the output. You will use various conditional and logical operators, as well as combinations of them, in a query and use regular expressions to find documents in a collection. By the end of this chapter, you will be able to run queries on arrays and nested objects, as well as limit, skip, and sort the records in the result set.

Introduction

In the previous chapters, we covered the basics of MongoDB, its document-based data model, data types, clients, and the MongoDB server. We created an Atlas cluster on the cloud, loaded sample datasets, and connected using ...

Get MongoDB Fundamentals now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.