Querying arrays and sub documents

I am really frustrated. First in an introductory course… Why would you make a lab that

  1. Is written wrong. There is no West of -74 latitude…Latitude runs north and south.

  2. There is no explanation on how to query a negative number… So… Entering this querry string in atlas returns 0. I used atlas so I could perfect the query, then I was going to use the terminal so I could use the .count() function.

<deleted, reason: potential answer>

This returns 0… But if you remove the - sign, it returns a value.

Tried to google mongo documentation on how to querry a negative number… Cannot find anything on it. Below is the lab write up.

Also in the atlas, the fields are 0 and 1… WHY would you name a field 0 and 1 in a .json based document??? It just makes it more confusing. Wouldn’t it be better to properly label your fields?

Please give feedback on this so I can complete the lab.

Hi @David_Thompson,

Apologize for the inconvenience caused to you while learning MongoDB. We are constantly working towards improving the course content and making the learner’s experience more interactive.


We have already fixed this issue a couple of weeks ago, so in upcoming offerings, changes will surely reflect. Moreover thanks for highlighting. We appreciate your efforts.

Here, we consider these as integers (either negative or positive) and you can surely write a query as normal using -1.

Here you have entered 1 after coordinates, I think that is creating issues for you.

But moreover here you have to answer the numbers of results you are getting. [As per question]

If you still have any further questions regarding this, feel free to mention them down here.

Thanks, Kushagra
1 Like

Thanks for listening… I got it with the following query.

db.trips.find({“start station location.coordinates.0”: {"$lte": -74 }}).count()

I am finding that I need to watch my field labels, as well as my spelling. Thank you for your patience.

1 Like