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 comparison operators

Finding documents by using comparison operators - MongoDB Tutorial

From the course: MongoDB C# Developer Associate Cert Prep

Finding documents by using comparison operators

- Hello there. In this video, you'll learn how to use comparison operators in MongoDB. We'll work with the following operators: gt, greater than, lt, less than, lte, less than or equal to and gte, greater than or equal to. The names of comparison operators follow a pattern so they're easy to remember. Note that each operator starts with a dollar sign to distinguish it from a field. To use a comparison operator, we specify a field followed by the comparison operator and a value. Let's go over each of the comparison operators to get a better idea of how they work. We'll start with gt, the greater than operator. It returns documents where the field contains a value greater than the specified value. Let's examine the following document which contains an items field that's an array of sub-documents. The items field contains various fields for each item including the price, which is what we're interested in. We…

Contents