I am using the web interface at cloud.mongodb.com. Perhaps Compass behaves differently (parses the entire input filter as a JavaScript expression, disabling the Find button if it is not valid) compared to the web interface (parses one object expression, ignoring everything after it, returning an error if it is not valid).
In the web interface, I created a test collection with three documents:
{"_id":{"$oid":"61129f0dd4d9c7314a7d858d"},"filter":"example","a":"a"}
{"_id":{"$oid":"61129f2bd4d9c7314a7d858f"},"filter":"example","a":"b"}
{"_id":{"$oid":"61129f3ad4d9c7314a7d8590"},"filter":"example2","a":"c"}
If the filter query is blank, all 3 documents are returned.
If I run the query abc
, the Find button is enabled, but I get this error:
The provided parameters were invalid. Check your query and try again.

Each of the following queries returns the first two documents without error:
{"filter":"example"}
{filter:"example"}
{"filter":"example"}abc
{"filter":"example"}!@#$%^&*()clearly invalid JS Expression!@#$%^&*()
{"filter":"example"},{"a":"c"}
This is contrary to the lecture video, which suggests that the last query would return documents that match either of the two queries: all documents that match {"filter":"example"}
or {"a":"c"}
.
If the comma operator is being applied in your version of Compass, it should return documents that match only the second operand of the comma operator, which is also contrary to the lecture video, as the first filter (the one before the comma) would be ignored.
Here’s a possible explanation for your observation: perhaps if the variable abc
is not defined, it causes the expression {},abc
to evaluate to undefined
, which results in no filter being applied.