pub fn value_to_bson_for_query(
schema: &ClassSchema,
field: &str,
value: &ParseValue,
) -> Result<Bson, ParseError>Expand description
Lower a value for use in a query filter on field.
Differs from the create path in one way that matters: a declared Pointer field stores
"Class$id", so a query for a pointer has to compare against that string rather than against
the __type envelope. Getting this wrong makes every pointer query silently return nothing.
A bare objectId string is prefixed too, and only the schema knows what to prefix it with.
transformTopLevelAtom’s string case is if (field && field.type === 'Pointer') return ${field.targetClass}$${atom}`` (MongoTransform.js:600-603), so {"author": {"$in": ["abc123"]}} compares against "Post$abc123" upstream. Handling only the __type envelope
left the raw-string form comparing against the unprefixed id, which matches no stored value:
the query answers 200 with no results rather than erroring, so nothing indicates the constraint
was meaningless. The class comes from the schema, not from the value, because a bare string
carries none.