Skip to main content

Eq

Equality comparison (left = right). Extends CompOperator. Shorthand keys: none (bare value, no suffix), =, eq.

Constructor

Eq(left: string | SqlElement, right: any): Eq
new Eq(left: string | SqlElement, right: any): Eq

Dual-callable. left can be a field-name string (optionally with a trailing [] to mark it an array field) or an SQL element (Field, Raw, sub-Select); right can be a literal, Param, Raw, or sub-Select.

import { Eq, Select } from '@sqb/builder';

Select().from('customers').where(Eq('id', 1));
// where id = 1

Properties

Inherits every property from CompOperator (_type, _left, _right, _symbol, _isArray); _symbol is always '='.

Methods

Inherits ._serialize() from CompOperator; Eq adds no methods of its own.

Object-literal shorthand

A plain-object key with no operator suffix (or an explicit =/eq suffix) builds an Eq:

Select().from('customers').where({ id: 1, 'name =': 'John', 'age eq': 30 });
// where id = 1 and name = 'John' and age = 30

See also