Using the sample_training.routes collection find out which of the following statements will return all routes that have at least one stop in them?

Using the sample_training.routes collection find out which of the following statements will return all routes that have at least one stop in them?
db.routes.find({ “stops”: { “$lt”: 10 }}).pretty()
db.routes.find({ “stops”: { “$gt”: 0 }}).pretty()
db.routes.find({ “stops”: { “$ne”: 0 }}).pretty()
db.routes.find({ “stops”: { “$gte”: 0 }}).pretty()

Answer should be all of the above, but the here it says option 2 and 3 only
i have ran all query in IDE and indeed it shows output >=1

The first one will not list routes with 10 and more stops, so not all routes are found.

The last one will list routes with 0 stops. 0 stops is not at least one stop.

1 Like

Hello @Ashish_Solanki

You probably remember intervals, but sometimes representing things help

You don’t want anything that includes 0, so :green_square: and :orange_square: are excluded.

2 Likes