Skip to content

toMongoFilter

toMongoFilter(where, toField?): Record<string, unknown>

Defined in: mongo-filter.ts:40

Translate a Mantle QueryParams.where clause into a MongoDB filter document.

Most operators ($lt/$lte/$gt/$gte/$ne/$in/$nin/$or/$and) are native MongoDB syntax and pass through unchanged; dot-path keys ("metadata.owner.name") are native too. The two Mantle-specific translations:

  • id keys become _id, with 24-hex string values converted to ObjectId — the repository boundary only ever deals in string ids.
  • $contains (jsonb @> semantics) becomes: scalar operand → field equality (MongoDB equality matches array elements natively), array operand → $all, object operand → recursively expanded dot-path conditions.

WhereClause

(field) => string

Record<string, unknown>