What's up with the quotes around the $gte and $lt in the quiz?

Hi,
Why does the query in the quiz look so different than what would appear in Compass tool Filter?
Are both ways ok to use? The spacing is a little different as well as the quotes and single quotes and lack of quotes. I"m new to MongoDB and this MongoDB Basics lesson is my first introduction to the query syntax.

in Quiz:
{“age”: {"$gte": 21, “$lt”: 70}}

in MongoDB Compass v1.16.0:
{‘birth year’: {$gte: 1985,$lt: 1990}}

Its confusing if a person expects to see one style of query syntax but then the lesson quiz disregards that.

@Nuno_54275 I believe the suggested/recommended syntax is with quotes (specifically for queries in embedded documents where dot notation is used in the key). But is recommended in all expressions for good practice even though it works without them currently. I’m assuming at some point they will sync the lab material with that as well.

See: Chapter 2: “The MongoDB Query Language + Atlas” / Reading Documents: Scalar Fields in the Lecture Notes

HTH,
Mike

HTH,
Mike

2 Likes

Hello Mike,
Thank you very much for the response and for helping to clarify this. I appreciate it.

Nuno.

1 Like