So it's Ketchikan state, so I hope I'm pronouncing that correct,
that has two zip codes, so you're basically displaying this as an array,
as part of the display that is coming back, and that's what push does.
So it's actually combining, and displaying it as an array.
So again it all depends, if you want to display this as two different documents in
your web application, then you will have to do something else which we'll look at.
But if you're trying to display this as in, hey,
this city has multiple zip codes, then you can do it using the push command.
Let's look at addToSet.
Now, addToSet is well, kind of opposite of what we did with first,
similar to what we did, kind of opposite.
So, what addToSet does is it'll actually return an array of all the unique
values that result from this applying of expression.
So basically if you look at these two examples, so the first one will basically
come back with every single state where you have this duplicate zip code problem,
whereas the second example will just give you the unique set of state,
so you might see hundreds of data coming back here, whereas here, you will get
just one distinct or one addToSet will come back with a unique value.
So for example, let's take some state called California.
California could have like ten cities which have multiple zip codes.
So you will see California come up ten times.
So each state will come up multiple times, assuming they have duplicate values.
Whereas addToSet will say, oh, I'm just going to show once California, and
the other state would come up one time.
So I think the best way to understand this is to look at an example, and
then we'll do the first one with push and then we'll replace that with addToSet,
and see how different the results come back.
So let's go, and do it first.
So this the command I'm going to do push state,
so as you can see, there's a whole bunch of data coming back.
So this state has so many cities and so many zip codes, and
all the duplicate values are coming back.
Now, we can take the exact same command, and we'll apply addToSet,
and this will filter out all the duplicate and will come back with one unique state.