Now that we have seen prediction, let's see how to use selection. Now the concept is the same thing, you have to specify an object representing conditions. For example, if I want to get all the content from city of Chicago, so I can do the same thing like DB dot contacts dot find. And the first argument would be the selection. And the second argument would be the projection. Let's say for example, I don't want to include the ID, I can simply say ID is zero.
However, we want to specify a condition here. And that condition would be city in Chicago, and save it. And let's go and run the same thing. Mongo x 04 dot js, you can see that we got some records now just to make sure that we see the data properly. That's also called the predict function, save it and re execute the same command. And this time, you can see we got some documents where the city property equals to Chicago, giving a key value pairs like this is equal and of saying city equals to Chicago.
So the same thing can also be represented using city. And then we specify an operator, which is given in the form of another object. So dollar EQ, and then we give Chicago. So now we are saying that city equals to Chicago. So output should remain the same thing. And we got the same thing.