Like
Pattern-matching comparison (left like right). Extends CompOperator.
Shorthand key: like.
Constructor
Like(left: string | SqlElement, right?: string | SqlElement): Like
new Like(left: string | SqlElement, right?: string | SqlElement): Like
Dual-callable. left can be a field-name string (optionally with a trailing []) or an SQL
element; right is coerced to a string if it isn't one already.
import { Like, Select } from '@sqb/builder';
Select().from('customers').where(Like('name', 'John%'));
// where name like 'John%'
Serializes to an empty string if right resolves to an empty string.
Properties
Inherits every property from CompOperator (_type, _left, _right,
_symbol, _isArray); _symbol is always 'like'.
Methods
Like overrides __serialize() to coerce a non-string right-hand expression to a string and to
skip serialization when it's empty; it adds no chainable methods of its own.
Object-literal shorthand
Select().from('customers').where({ 'name like': 'John%' });
// where name like 'John%'