From the course: MongoDB C# Developer Associate Cert Prep

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Finding documents by using logical operators

Finding documents by using logical operators - MongoDB Tutorial

From the course: MongoDB C# Developer Associate Cert Prep

Finding documents by using logical operators

- Hello. In this video you'll learn how to use logical operators in MongoDB. The logical operators we'll work with are $and and $or. Let's start with $and. The and operator performs a logical and operation on an array of one or more expressions. It will return all documents that meet all the criteria specified in the array. The and operator also has an implicit syntax that we often use to simplify a query expression. All we need to do is add a comma between each query expression. This comma acts just like the and operator. When using the and operator, remember that if any one of the criteria isn't met in a given document, the document will not be included in the results. Before we dive into an example, let's examine a sample document from a collection called Routes. Every document in this collection holds information about a particular flight route, like the number of stops, type of airplane, airline, source…

Contents