There is also a simple mechanism to work with conditions. This can be done with the help of $1 where operator which takes a string, representing a condition. However, these conditions would operate on the properties using the JavaScript notation. Let's take an example. dB dot sales dot find dollar where and a string. And here, the properties must be accessed with the help of this keyword with this represents the current object or current document being processed.
So what MongoDB does is MongoDB going to take every document in the sales collection one by one, and checks this condition. Is it true for the current document? And if that is true for the current document that is prepared for the output? If not, it's ignored. So if I do hear this start quarter equals two equals to one, notice that double equals because this is JavaScript, and then I can say R. And I can say this dot quarter equals to equals to three. This has the exact same condition as in the dollar or operator where we said quarter equals to one quarter equals to three.
So let's give it a try and say how many documents match this condition. So I'm going to go type here, Mongo, e x 09 dot j s, and it's coming back with 138. So if I go and change this to save, for example, for now, I should see a different result. We can also say something like this dot sales underscore amount greater than or equals to 5000. And this dot sales underscore amount less than or equal to 6000. So this is a very simple mechanism to execute a query.