Skip to main content

NotIn

Negated set-membership comparison (left not in (right...)). Extends In. Shorthand keys: notIn, nin, !in.

Constructor

NotIn(left: string | SqlElement, right: any[]): NotIn
new NotIn(left: string | SqlElement, right: any[]): NotIn

Dual-callable, same argument shape as In.

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

Select().from('customers').where(NotIn('id', [1, 2, 3]));
// where id not in (1,2,3)

An empty array is special-cased the other way from In: NotIn('id', []) serializes to the literal 1=1 (always true) instead of an empty not in ().

Properties

Inherits every property from In (_type, _left, _right, _symbol, _isArray); _symbol is always 'not in'.

Methods

Inherits ._serialize() from In (including the empty-array special case, which flips to 1=1 for NotIn); it adds no methods of its own.

Object-literal shorthand

Select().from('customers').where({ 'status !in': ['deleted', 'banned'], 'id notIn': [1, 2] });
// where status not in ('deleted','banned') and id not in (1,2)

See also