So now what I get back here is for Maryland.
So look at the location that's different, one for New York and one for Maryland.
So this is again an interesting
combination where I can send in more than one hash.
Now you can send more, we can send three or four or five.
This is basically doing the find with additional parameters.
Now in the previous few slides ago we saw that Mongoose approach,
well the find can come back with the cursor object, right?
The cursor reiterations.
Now when you have more than one document in the collection
that meets the criteria, what comes back is a collection.
Right. A collection of data.
So if you want to print that or parse that or
process that, then you will have to to go through the collection and
pull each document out and process it or print it in our case.
So you can accomplish that by doing the .each.
The .each will actually print out, in this example, as you can see,
it's printing out the r or the result.
So, if you run this command we should get the 29,000 plus documents.
Almost 30,000 documents will get displayed on the screen.
So let's go and try that command.
Now, this is the command that will go and pull every single document and
print on the screen.
Now, I'm going to warn you that we will see a lot of documents get
printed on the screen, obviously every single one, so
I'm going to do a Ctrl+C once we see the first few documents get printed.
But that's the command, db[:zips].find().each, and
then we will do a print of the r, which is a result in our case.
So as I said once I hit Enter,
you will see a lot of documents come up on the screen.
So give this a try and you will see all this documents coming up on the screen.
So I'm going to stop this or abort this because we select 14,000 there.
So I'm going to do a system.clear, right, that'll clear the screen.
So just to recall.
This is the command that's going to print everything on the screen.
And again if you have data that you want to go through,
you can type this command to get all the data.
So the next we'll look at in find is Projections.
Now what is projections?
Projections is similar to select in relational database.
It will limit the fields to return from all the matching documents, right.
So you can specify the inclusion or exclusion.
So you want to say select first name last name and middle name from the employee and
ignore everything else right, that's what you do in a relational database.
So here, what you would do is you will include which is true or
1 and exclude which is false or 0.
So either you will make a property inclusive or
exclusive and this is how you will filter out the data.
Now a good example is this, remember id is a primary key in Mongo.
So Mongo by default, whether you ask or not right, it will automatically
include _id by default as part of your select or part of your find query.
Now there might be instance where you don't rally need the id to come back
then you can go and turn this off by making this again,
by inclusive or exclusive you can control the showing of id.
Now again id's default, right, but by default it's shown, but
you can turn this off by setting it to false or to 0.
So let's see an example of this.
Okay so let's see the first example where we will do a simple
find the state and state colon true.
So, this is saying, okay, show me the state.
Now, notice we are not doing anything with ID, right?
We're not projecting ID at all, and guess what?
We get ID by default, because Mongo automatically sensed this.
Now if we turn this off,
like if we don't really care about the id, then we need to set the id as false.
So let's give that a try.