Quotes or no quotes in filter?

When does one need to put the key in quotes?
For 100YWeatherSmall
The filter:
{wind.type:“C”} yields an error
but
{“wind.type”:“C”} executes

Off the top of my head:

  • multi-level fields like in your example, i.e. when you need to use a dot to reference a field one or more levels down
  • field names that contain spaces
  • field names that contain special characters, for example if your field name contains a dot etc

There are some other cases beyond the scope of this course.

Thank you. However, I see that Shannon got away no quotes for the key in Compass while I did not.

Howard

Sorry, I didn’t take this particular course. Can you share a screenshot of what she did so I can see what you’re referring to?
It’s most certainly a requirement to quote this particular type of field.

She’s most likely running a version of Compass that implicitly quotes before sending to the db. She’s also running a very old version of MongoDB (3.4.4), I wonder if that also has a bearing. I’m leaning towards the former.

Hi @Howard_84497,

I hope you found the post #2 helpful.

It was an older version of Compass which permitted this operation. The newer version does not allow this. The same has been mentioned in the lecture notes as well.

Hope it helps!

Thanks,
Shubham Ranjan
Curriculum Support Engineer

Hi @007_jb,

Yes, your intution is correct. Older version of Compass allowed this.

Thanks,
Shubham Ranjan
Curriculum Support Engineer

:slightly_smiling_face: :+1: