Interface WhereOperators<AttributeType>

Operators that can be used in WhereOptions

interface WhereOperators<AttributeType> {
    [adjacent]?: AttributeType extends Range<RangeType>
        ? Rangable<RangeType>
        : DynamicValues<AttributeType>;
    [allKeysExist]?: string[] | DynamicValues<string[]>;
    [anyKeyExists]?: string[] | DynamicValues<string[]>;
    [between]?: Literal | [lowerInclusive: OperatorValues<NonNullable<AttributeType>>, higherInclusive: OperatorValues<NonNullable<AttributeType>>];
    [contained]?: AttributeType extends any[]
        ? undefined | AllowAnyAll<(DynamicValues<AttributeType> | (AttributeType extends Range<infer RangeType> ? Rangable<RangeType> : AttributeType extends any[] ? StaticValues<...> : never))>
        : AllowAnyAll<OperatorValues<Rangable<AttributeType>>>;
    [contains]?: AttributeType extends Range<RangeType>
        ? OperatorValues<OperatorValues<NonNullable<RangeType>>>
        : AttributeType extends object
            ? OperatorValues<Partial<AttributeType<AttributeType>>>
            : undefined | AllowAnyAll<(DynamicValues<AttributeType> | (AttributeType extends Range<infer RangeType> ? Rangable<RangeType> : AttributeType extends any[] ? StaticValues<...> : never))>;
    [endsWith]?: OperatorValues<Extract<AttributeType, string>>;
    [eq]?: AllowAnyAll<OperatorValues<AttributeType>>;
    [gt]?: AllowAnyAll<OperatorValues<NonNullable<AttributeType>>>;
    [gte]?: AllowAnyAll<OperatorValues<NonNullable<AttributeType>>>;
    [iLike]?: AllowAnyAll<OperatorValues<Extract<AttributeType, string>>>;
    [iRegexp]?: AllowAnyAll<OperatorValues<Extract<AttributeType, string>>>;
    [in]?: Literal | readonly OperatorValues<NonNullable<AttributeType>>[];
    [isNot]?: Literal | Extract<AttributeType, null | boolean>;
    [is]?: Literal | Extract<AttributeType, null | boolean>;
    [like]?: AllowAnyAll<OperatorValues<Extract<AttributeType, string>>>;
    [lt]?: AllowAnyAll<OperatorValues<NonNullable<AttributeType>>>;
    [lte]?: AllowAnyAll<OperatorValues<NonNullable<AttributeType>>>;
    [match]?: AllowAnyAll<DynamicValues<AttributeType>>;
    [ne]?: AllowAnyAll<OperatorValues<AttributeType>>;
    [noExtendLeft]?: AttributeType extends Range<RangeType>
        ? Rangable<RangeType>
        : DynamicValues<AttributeType>;
    [noExtendRight]?: AttributeType extends Range<RangeType>
        ? Rangable<RangeType>
        : DynamicValues<AttributeType>;
    [notBetween]?: Literal | [lowerInclusive: OperatorValues<NonNullable<AttributeType>>, higherInclusive: OperatorValues<NonNullable<AttributeType>>];
    [notEndsWith]?: OperatorValues<Extract<AttributeType, string>>;
    [notILike]?: AllowAnyAll<OperatorValues<Extract<AttributeType, string>>>;
    [notIRegexp]?: AllowAnyAll<OperatorValues<Extract<AttributeType, string>>>;
    [notIn]?: Literal | readonly OperatorValues<NonNullable<AttributeType>>[];
    [notLike]?: AllowAnyAll<OperatorValues<Extract<AttributeType, string>>>;
    [notRegexp]?: AllowAnyAll<OperatorValues<Extract<AttributeType, string>>>;
    [notStartsWith]?: OperatorValues<Extract<AttributeType, string>>;
    [notSubstring]?: OperatorValues<Extract<AttributeType, string>>;
    [overlap]?: AllowAnyAll<(DynamicValues<AttributeType> | (AttributeType extends Range<infer RangeType> ? Rangable<RangeType> : AttributeType extends any[] ? StaticValues<...> : never))>;
    [regexp]?: AllowAnyAll<OperatorValues<Extract<AttributeType, string>>>;
    [startsWith]?: OperatorValues<Extract<AttributeType, string>>;
    [strictLeft]?: AttributeType extends Range<RangeType>
        ? Rangable<RangeType>
        : DynamicValues<AttributeType>;
    [strictRight]?: AttributeType extends Range<RangeType>
        ? Rangable<RangeType>
        : DynamicValues<AttributeType>;
    [substring]?: OperatorValues<Extract<AttributeType, string>>;
}

Type Parameters

Properties

[adjacent]?: AttributeType extends Range<RangeType>
    ? Rangable<RangeType>
    : DynamicValues<AttributeType>

PG only

Whether the two ranges are adjacent.

Example

{ rangeAttribute: { [Op.adjacent]: [1, 2] } }
// results in
// "rangeAttribute" -|- [1, 2)

https://www.postgresql.org/docs/14/functions-range.html

[allKeysExist]?: string[] | DynamicValues<string[]>

PG only

Check if all of these array strings exist as top-level keys.

Example

{ jsonbAttribute: { [Op.allKeysExist]: ['a','b'] } }
// results in
// "jsonbAttribute" ?& ARRAY['a','b']

https://www.postgresql.org/docs/current/functions-json.html

[anyKeyExists]?: string[] | DynamicValues<string[]>

PG only

Check if any of these array strings exist as top-level keys.

Example

{ jsonbAttribute: { [Op.anyKeyExists]: ['a','b'] } }
// results in
// "jsonbAttribute" ?| ARRAY['a','b']

https://www.postgresql.org/docs/current/functions-json.html

[between]?: Literal | [lowerInclusive: OperatorValues<NonNullable<AttributeType>>, higherInclusive: OperatorValues<NonNullable<AttributeType>>]

Example

`[Op.between]: [6, 10],` becomes `BETWEEN 6 AND 10`
[contained]?: AttributeType extends any[]
    ? undefined | AllowAnyAll<(DynamicValues<AttributeType> | (AttributeType extends Range<infer RangeType> ? Rangable<RangeType> : AttributeType extends any[] ? StaticValues<...> : never))>
    : AllowAnyAll<OperatorValues<Rangable<AttributeType>>>

PG array & range 'contained by' operator

Example

`[Op.contained]: [1, 2]` becomes `<@ [1, 2]`
[contains]?: AttributeType extends Range<RangeType>
    ? OperatorValues<OperatorValues<NonNullable<RangeType>>>
    : AttributeType extends object
        ? OperatorValues<Partial<AttributeType<AttributeType>>>
        : undefined | AllowAnyAll<(DynamicValues<AttributeType> | (AttributeType extends Range<infer RangeType> ? Rangable<RangeType> : AttributeType extends any[] ? StaticValues<...> : never))>

PG array & range 'contains' operator

Example

`[Op.contains]: [1, 2]` becomes `@> [1, 2]`
[endsWith]?: OperatorValues<Extract<AttributeType, string>>

String ends with value.

Example

`[Op.eq]: 6,` becomes `= 6`

Example

`[Op.eq]: [6, 7]` becomes `= ARRAY[6, 7]`

Example

`[Op.eq]: null` becomes `IS NULL`

Example

`[Op.eq]: true` becomes `= true`

Example

`[Op.eq]: literal('raw sql')` becomes `= raw sql`

Example

`[Op.eq]: col('column')` becomes `= "column"`

Example

`[Op.eq]: fn('NOW')` becomes `= NOW()`

Example

`[Op.gt]: 6` becomes `> 6`

Example

`[Op.gte]: 6` becomes `>= 6`

case insensitive PG only

Example

`[Op.iLike]: '%hat'` becomes `ILIKE '%hat'`

Example

`[Op.iLike]: { [Op.any]: ['cat', 'hat']}` becomes `ILIKE ANY (ARRAY['cat', 'hat'])`

PG only

Matches regular expression, case insensitive

Example

`[Op.iRegexp]: '^[h|a|t]'` becomes `~* '^[h|a|t]'`

Example

`[Op.in]: [1, 2],` becomes `IN (1, 2)`
[isNot]?: Literal | Extract<AttributeType, null | boolean>

Example: [Op.isNot]: null, becomes IS NOT NULL

[is]?: Literal | Extract<AttributeType, null | boolean>

Example

`[Op.is]: null` becomes `IS NULL`

Example

`[Op.is]: true` becomes `IS TRUE`

Example

`[Op.is]: literal('value')` becomes `IS value`

Example

`[Op.like]: '%hat',` becomes `LIKE '%hat'`

Example

`[Op.like]: { [Op.any]: ['cat', 'hat'] }` becomes `LIKE ANY (ARRAY['cat', 'hat'])`

Example

`[Op.lt]: 10` becomes `< 10`

Example

`[Op.lte]: 10` becomes `<= 10`

Example

`[Op.match]: Sequelize.fn('to_tsquery', 'fat & rat')` becomes `@@ to_tsquery('fat & rat')`

Example

`[Op.ne]: 20,` becomes `!= 20`

Example

`[Op.ne]: [20, 21]` becomes `!= ARRAY[20, 21]`

Example

`[Op.ne]: null` becomes `IS NOT NULL`

Example

`[Op.ne]: true` becomes `!= true`

Example

`[Op.ne]: literal('raw sql')` becomes `!= raw sql`

Example

`[Op.ne]: col('column')` becomes `!= "column"`

Example

`[Op.ne]: fn('NOW')` becomes `!= NOW()`
[noExtendLeft]?: AttributeType extends Range<RangeType>
    ? Rangable<RangeType>
    : DynamicValues<AttributeType>

PG only

Whether the range extends to the left of the other range.

Example

{ rangeAttribute: { [Op.noExtendLeft]: [1, 2] } }
// results in
// "rangeAttribute" &> [1, 2)

https://www.postgresql.org/docs/14/functions-range.html

[noExtendRight]?: AttributeType extends Range<RangeType>
    ? Rangable<RangeType>
    : DynamicValues<AttributeType>

PG only

Whether the range extends to the right of the other range.

Example

{ rangeAttribute: { [Op.noExtendRight]: [1, 2] } }
// results in
// "rangeAttribute" &< [1, 2)

https://www.postgresql.org/docs/14/functions-range.html

[notBetween]?: Literal | [lowerInclusive: OperatorValues<NonNullable<AttributeType>>, higherInclusive: OperatorValues<NonNullable<AttributeType>>]

Example

`[Op.notBetween]: [11, 15],` becomes `NOT BETWEEN 11 AND 15`
[notEndsWith]?: OperatorValues<Extract<AttributeType, string>>

String not ends with value.

PG only

Example

`[Op.notILike]: '%hat'` becomes `NOT ILIKE '%hat'`

Example

`[Op.notILike]: { [Op.any]: ['cat', 'hat']}` becomes `NOT ILIKE ANY (ARRAY['cat', 'hat'])`

PG only

Does not match regular expression, case insensitive

Example

`[Op.notIRegexp]: '^[h|a|t]'` becomes `!~* '^[h|a|t]'`

Example

`[Op.notIn]: [1, 2],` becomes `NOT IN (1, 2)`

Example

`[Op.notLike]: '%hat'` becomes `NOT LIKE '%hat'`

Example

`[Op.notLike]: { [Op.any]: ['cat', 'hat']}` becomes `NOT LIKE ANY (ARRAY['cat', 'hat'])`

MySQL/PG only

Does not match regular expression, case sensitive

Example

`[Op.notRegexp]: '^[h|a|t]'` becomes `NOT REGEXP/!~ '^[h|a|t]'`
[notStartsWith]?: OperatorValues<Extract<AttributeType, string>>

Strings not starts with value.

[notSubstring]?: OperatorValues<Extract<AttributeType, string>>

String not contains value.

[overlap]?: AllowAnyAll<(DynamicValues<AttributeType> | (AttributeType extends Range<infer RangeType> ? Rangable<RangeType> : AttributeType extends any[] ? StaticValues<...> : never))>

PG array & range 'overlaps' operator

Example

`[Op.overlap]: [1, 2]` becomes `&& [1, 2]`

MySQL/PG only

Matches regular expression, case sensitive

Example

`[Op.regexp]: '^[h|a|t]'` becomes `REGEXP/~ '^[h|a|t]'`
[startsWith]?: OperatorValues<Extract<AttributeType, string>>

Strings starts with value.

[strictLeft]?: AttributeType extends Range<RangeType>
    ? Rangable<RangeType>
    : DynamicValues<AttributeType>

PG only

Whether the range is strictly left of the other range.

Example

{ rangeAttribute: { [Op.strictLeft]: [1, 2] } }
// results in
// "rangeAttribute" << [1, 2)

https://www.postgresql.org/docs/14/functions-range.html

[strictRight]?: AttributeType extends Range<RangeType>
    ? Rangable<RangeType>
    : DynamicValues<AttributeType>

PG only

Whether the range is strictly right of the other range.

Example

{ rangeAttribute: { [Op.strictRight]: [1, 2] } }
// results in
// "rangeAttribute" >> [1, 2)

https://www.postgresql.org/docs/14/functions-range.html

[substring]?: OperatorValues<Extract<AttributeType, string>>

String contains value.