Match
A comparison operator intended purely as an extension point for dialect-specific full-text search
(MATCH() AGAINST() in MySQL, @@ in Postgres, CONTAINS() in SQL Server, ...). Extends
CompOperator. Shorthand key: match.
Constructor
Match(left: string | SqlElement, right?: string | SqlElement, customArgs?: any): Match
new Match(left: string | SqlElement, right?: string | SqlElement, customArgs?: any): Match
Dual-callable. left/right follow the same rules as Like;
customArgs is an arbitrary value stashed on the instance for a SerializerExtension to read
back during serialization.
import { Match, Select } from '@sqb/builder';
Select().from('articles').where(Match('body', 'search terms'));
By itself Match serializes exactly like Eq (field = 'value') — @sqb/builder
ships no built-in full-text syntax. A SerializerExtension registered for
SerializationType.COMPARISON_EXPRESSION can inspect _operatorType === OperatorType.match (or
the customArgs passed as the third constructor argument) and render the dialect-specific syntax
instead. See
Generating SQL per dialect.
Properties
Inherits every property from CompOperator (_type, _left, _right,
_symbol, _isArray); _symbol defaults to '='. Adds:
| Key | Type | Readonly | Description |
|---|---|---|---|
customArgs | any | No | Arbitrary dialect-specific data, set from the constructor's third argument. |
Methods
Match overrides __serialize() to coerce a non-string right-hand expression to a string, skip
serialization when it's empty, and forward customArgs to the serializer; it adds no chainable
methods of its own.
Object-literal shorthand
Select().from('articles').where({ 'body match': 'search terms' });