From the course: MongoDB Code Challenges: From Beginner to Advanced
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Find: Query operators { $gte, $in: [], etc } - MongoDB Tutorial
From the course: MongoDB Code Challenges: From Beginner to Advanced
Find: Query operators { $gte, $in: [], etc }
- [Instructor] Welcome to CRUD Challenge four, Query Operators. Searching for data rarely involves simplistic name equals John type of queries. Often, we need to know if a raise include a value or if a number is greater than or equal to some other value, or if a date falls within some range. This is where the notion of query operators comes into play. For a normal field search, the syntax is simple. The object for the key is the field name and the value is what you're searching for. Query operators can take the place of that value. So instead of a simple query such as name equals John, you can use a query operator like Name, $, equal John to do the same thing. Here's the Query Operator is this $eq. You'll see it in the bottom example there where you're saying instead of just saying pure value, equal runs a function behind the scenes that checks for the name equal to a thing. Yes, that's more typing. Yes, that's less clear, but as your query needs to become more advanced, the ability…
Contents
-
-
-
-
(Locked)
Find: Query with a simple filter9m 3s
-
(Locked)
Find: Specify which fields to return in a .find()5m 49s
-
(Locked)
Find: Sorting and limiting10m 14s
-
(Locked)
Find: Query operators { $gte, $in: [], etc }7m 55s
-
(Locked)
Find: Values in subdocuments and objects8m 37s
-
(Locked)
Find: Values in arrays9m 38s
-
(Locked)
Find: $and and $or queries6m 12s
-
(Locked)
Find: Custom query logic with functions6m 52s
-
(Locked)
-
-
-
-
-