routier-collection / core/src / ComparatorExpression
Class: ComparatorExpression
Defined in: core/src/expressions/types.ts:270
A class representing a comparison operation (e.g., equals, greater-than).
Extends
Constructors
Constructor
new ComparatorExpression(
options):ComparatorExpression
Defined in: core/src/expressions/types.ts:280
Parameters
options
comparator
negated
boolean
strict
boolean
left?
right?
Returns
ComparatorExpression
Overrides
Properties
left?
optionalleft:Expression
Defined in: core/src/expressions/types.ts:100
The left-hand side of the expression (if applicable).
Inherited from
right?
optionalright:Expression
Defined in: core/src/expressions/types.ts:102
The right-hand side of the expression (if applicable).
Inherited from
type
readonlytype:"comparator"
Defined in: core/src/expressions/types.ts:272
The type of the expression (always 'comparator').
Overrides
comparator
comparator:
Comparator
Defined in: core/src/expressions/types.ts:274
The comparator operation (e.g., equals, greater-than).
negated
negated:
boolean
Defined in: core/src/expressions/types.ts:276
Whether the comparison is negated (e.g., not equals).
strict
strict:
boolean
Defined in: core/src/expressions/types.ts:278
Whether the comparison is strict (type-sensitive).
Accessors
EMPTY
Get Signature
get
staticEMPTY():EmptyExpression
Defined in: core/src/expressions/types.ts:109
Returns
Inherited from
NOT_PARSABLE
Get Signature
get
staticNOT_PARSABLE():NotParsableExpression
Defined in: core/src/expressions/types.ts:113
Returns
Inherited from
Methods
isEmpty()
staticisEmpty(expression):boolean
Defined in: core/src/expressions/types.ts:117
Parameters
expression
Returns
boolean
Inherited from
isNotParsable()
staticisNotParsable(expression):boolean
Defined in: core/src/expressions/types.ts:121
Parameters
expression
Returns
boolean
Inherited from
toJson()
statictoJson(expression):SerializedExpression
Defined in: core/src/expressions/types.ts:147
Turns a tree into plain JSON, so a whole query can cross a wire.
On the class rather than beside it, because this is the type's own REPRESENTATION — there is one right answer and it belongs with the thing being represented, next to EMPTY and isEmpty. Rendering a tree into some other language (toSql, toMql, evaluate) is a different kind of thing: there are many, each belongs to its consumer, and none of them is canonical.
Why it is this small
Of the six node types a bound tree can contain, exactly one holds anything JSON cannot carry: PropertyExpression, whose live PropertyInfo has functions, a parent chain and caches. It reduces to a property PATH — PropertyInfo.id IS the dotted path, and getProperty is keyed by exactly that — so rebinding is one lookup.
ParamReferenceExpression never appears: it is a parse-time placeholder that binding replaces with a plain ValueExpression holding the resolved value. A serialized tree is always already bound, so there is no params object to send alongside it.
Switches on type rather than using the isXExpression guards, which live in ../assertions and import this module — the guards test the same discriminant, so nothing is lost.
Parameters
expression
Returns
Inherited from
fromJson()
staticfromJson(json,schema):Expression
Defined in: core/src/expressions/types.ts:211
Rebuilds a tree from JSON, rebinding every property against schema.
The schema is SUPPLIED rather than read out of the payload. A filter always belongs to a known collection, and the RECEIVER's schema is the authority on what its properties are — taking an id from the payload would mean rebinding against a schema the sender chose, which is backwards for anything crossing a trust boundary.
Parameters
json
schema
CompiledSchemaCore<any>
Returns
Throws
when a property path is not declared by schema. Not NOT_PARSABLE: on a receiver, a filter that silently stops filtering returns rows the requester excluded, which is the one failure here worse than an error.