Chapter2 Quiz(Finding end station name)

{"birth year":1961,"start station name":"Howard St & Centre St"}
How to extract exact ‘end station name’ ?

1 Like

db.collection.find(query, "end station name":1, _id:0}

Using projection

So I have re-watched the video a few times now, why is it that for this one in particular the field name is in quotations but the value is not? In the Example from the video {“state”:“NY”} was used and additional filters were added with the same format. Is it because in this case the data set does not also have the value in quotations? I was assuming the correct search parameters would have been {“birth year”:“1961”}… Thank you for any help on this!

Numbers are not in quotes.

There are exceptions. The best thing to do is to know the data. If you have Compass install, select the collection and then go in the Schema and run Analyse Schema. You will see that birth year is of type int32, a number so the values are not in quotes.

As for the field name, in JavaScript you may omit the quotes and use { state : “NY” }, however if you have spaces or dots in the field name, like birth year and imdb.rating, you need quotes. In my opinion, it is best to always use quotes for field name.

1 Like