JSON can carry instructions as easily as it carries values. If an endpoint copies a submitted object into a database filter, a value such as a not-equal operator can change which records match. Checking that the field is present or truthy doesn't establish that it's a string.
Define the expected types at the request boundary and build the query yourself. These exercises accept two scalar string values and perform exact equality comparisons. Arrays, objects, null and numbers are outside that contract. The visible vulnerable matcher models equality and the $ne operator only; it's not MongoDB or a full NoSQL parser. The lesson is the data-to-query boundary, not a catalog of payloads. A production service also needs tenant authorization, driver-safe query construction and restricted database privileges. Preserve an empty result when a valid scalar query matches nothing.
Reject caller-supplied query operators and build equality filters.