TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/abejarano/ts-mongo-criteria/llms.txt
Use this file to discover all available pages before exploring further.
Operator enum is the authoritative list of every comparison and logical operator that ts-mongo-criteria understands. When you construct a FilterOperator you choose one of these twelve members — the MongoCriteriaConverter then maps each member to its MongoDB equivalent when building the final query document.
Operator enum reference
| Enum member | String value | MongoDB operator | Required value type |
|---|---|---|---|
EQUAL | "=" | $eq | FilterPrimitive |
NOT_EQUAL | "!=" | $ne | FilterPrimitive |
GT | ">" | $gt | FilterPrimitive |
GTE | ">=" | $gte | FilterPrimitive |
LT | "<" | $lt | FilterPrimitive |
LTE | "<=" | $lte | FilterPrimitive |
CONTAINS | "CONTAINS" | $regex (case-insensitive) | FilterPrimitive (string) |
NOT_CONTAINS | "NOT_CONTAINS" | $not + $regex | FilterPrimitive (string) |
BETWEEN | "BETWEEN" | $gte + $lte | BetweenValue |
OR | "OR" | $or | OrCondition[] |
IN | "IN" | $in | FilterPrimitive[] |
NOT_IN | "NOT_IN" | $nin | FilterPrimitive[] |
FilterOperator class
FilterOperator wraps a single Operator enum member. It is what you pass as the second argument to the Filter constructor.
constructor(value: Operator)
Instantiate directly from an enum member when you know the operator at compile time.
static fromValue(value: string): FilterOperator
Parses a raw string into a FilterOperator. This is the method Filter.fromValues() calls internally, so it is also what runs when you pass operator strings to Filters.fromValues().
The string you pass must exactly match one of the twelve
Operator string
values listed in the table above (e.g. "=", "BETWEEN", "NOT_IN").
Matching is case-sensitive.InvalidArgumentError
FilterOperator.fromValue() (and OrderType.fromValue()) throw an InvalidArgumentError when the supplied string does not correspond to any known enum member. Catch it wherever you accept operator strings from untrusted sources such as query parameters.
Example — Operator.BETWEEN with BetweenValue
BETWEEN into a $gte / $lte pair:
Example — Operator.OR with OrCondition[]
OR operator into a MongoDB $or array: