From the course: MongoDB Essential Training
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Logical operators - MongoDB Tutorial
From the course: MongoDB Essential Training
Logical operators
- [Instructor] There are four logical operators that you can use in MongoDB, $and, $or, $nor and $not. Let's look at each one separately. Once again, we're going to be using the sample data database. If you have switched ranges, type in use sample data. All right, now, we're going to be using the inventory collection. So let's just briefly remind ourselves what a document in that collection looks like. Cool, okay, so now, let's look at each operator, starting with $and, and I'm going to just start writing a query to show you what that looks like, and we're going to be using the $and operator. So I'm going to start with that. Cool, so the $and operator takes an array of multiple documents. Each document specifies a condition that documents have to match in order to be in the results set. So in more general terms, the $and operator allows me to query for items that match multiple conditions. So I could, for example…
Contents
-
-
-
-
-
-
(Locked)
insertOne and insertMany4m 58s
-
(Locked)
findOne and find7m 49s
-
(Locked)
Comparison operators6m 11s
-
(Locked)
Logical operators7m 55s
-
(Locked)
Sort, skip, limit4m 8s
-
(Locked)
updateOne and updateMany4m 36s
-
(Locked)
Arrays10m 2s
-
(Locked)
Transactions5m 2s
-
(Locked)
$expr5m 28s
-
(Locked)
Challenge: Create app1m 22s
-
(Locked)
Solution: Create app6m
-
(Locked)
-
-
-
-