MongoDB for Developers with Python Transcripts
Chapter: MongoDB's shell and native query syntax
Lecture: Concept: Advanced queries
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
So here's the list of the quering operators, all the complex ones. So we saw that normally we pass these prototypical json objects,
0:08
ratings.values is five, and that just doesn't exactly match, but we saw that that doesn't really solve all our problems,
0:15
often we want ranges or properties like I want all of the ratings that are greater than eight, things like that;
0:21
so instead of putting a number into that prototypical json element, we're going to put an operator, so we might say $eq for equality
0:28
that's kind of the same thing, but the others are not, so $gt for greater than, greater than or equal to, lt for less than, less than or equal to,
0:35
not equal to, so you could say I want to see all the ones where there's no vote, or no rating of value ten, right,
0:43
there's no rating that has a value of ten. And we talked about the in operator, this is kind of your two step join process
0:49
that we'll talk much more about when we get to the Python side of things, there's also the inverse of that negation, not in the set.
0:55
So here's an example how we might use the greater than or equal to operator to find all the books that have a rating of nine or ten
1:02
that are super highly rated by at least one person, remember this is not like every single one in there has to be this,
1:08
but there exists of rating which is a nine or a ten. We also have some joining operators or some combining operators joining,
1:15
so we can go in and say and pretty easily by just having all the properties we're looking for in a single document,
1:22
but if for some reason these are coming from multiple places you can actually combine them with the and operator
1:27
so that's nice, but what you really sometimes need is the or clause, I want this or that, and there's no way to do that those prototypical json objects
1:36
but the or operator will let you do this. You also have not and nor, so neither of these in an or, sort of the negation of an or;
1:44
now I recommend you check out this link at the bottom for each one of them, like so where the operator appears, does it appear to the right hand side
1:51
of the property or field name or the left hand side, it kind of depends on the type of operator you're using,
1:57
so you can just click on this or the and and so on and in the docks and it'll give you a little example.