Interface WhereOperators<AttributeType>

Operators that can be used in WhereOptions

Type Parameters

Hierarchy

  • WhereOperators

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<RangeType>
        ? Rangable<RangeType>
        : AttributeType extends any[]
            ? StaticValues<NonNullable<AttributeType>>
            : 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>>
        : undefined | AllowAnyAll<DynamicValues<AttributeType> | (AttributeType extends Range<RangeType>
            ? Rangable<RangeType>
            : AttributeType extends any[]
                ? StaticValues<NonNullable<AttributeType>>
                : never)>

PG array & range 'contains' operator

Example

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

String ends with value.

[eq]?: AllowAnyAll<OperatorValues<AttributeType>>

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()`
[gt]?: AllowAnyAll<OperatorValues<NonNullable<AttributeType>>>

Example

`[Op.gt]: 6` becomes `> 6`
[gte]?: AllowAnyAll<OperatorValues<NonNullable<AttributeType>>>

Example

`[Op.gte]: 6` becomes `>= 6`
[iLike]?: AllowAnyAll<OperatorValues<Extract<AttributeType, string>>>

case insensitive PG only

Example

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

Example

`[Op.iLike]: { [Op.any]: ['cat', 'hat']}` becomes `ILIKE ANY (ARRAY['cat', 'hat'])`
[iRegexp]?: AllowAnyAll<OperatorValues<Extract<AttributeType, string>>>

PG only

Matches regular expression, case insensitive

Example

`[Op.iRegexp]: '^[h|a|t]'` becomes `~* '^[h|a|t]'`
[in]?: Literal | readonly OperatorValues<NonNullable<AttributeType>>[]

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`
[like]?: AllowAnyAll<OperatorValues<Extract<AttributeType, string>>>

Example

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

Example

`[Op.like]: { [Op.any]: ['cat', 'hat'] }` becomes `LIKE ANY (ARRAY['cat', 'hat'])`
[lt]?: AllowAnyAll<OperatorValues<NonNullable<AttributeType>>>

Example

`[Op.lt]: 10` becomes `< 10`
[lte]?: AllowAnyAll<OperatorValues<NonNullable<AttributeType>>>

Example

`[Op.lte]: 10` becomes `<= 10`
[match]?: AllowAnyAll<DynamicValues<AttributeType>>

Example

`[Op.match]: Sequelize.fn('to_tsquery', 'fat & rat')` becomes `@@ to_tsquery('fat & rat')`
[ne]?: AllowAnyAll<OperatorValues<AttributeType>>

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.

[notILike]?: AllowAnyAll<OperatorValues<Extract<AttributeType, string>>>

PG only

Example

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

Example

`[Op.notILike]: { [Op.any]: ['cat', 'hat']}` becomes `NOT ILIKE ANY (ARRAY['cat', 'hat'])`
[notIRegexp]?: AllowAnyAll<OperatorValues<Extract<AttributeType, string>>>

PG only

Does not match regular expression, case insensitive

Example

`[Op.notIRegexp]: '^[h|a|t]'` becomes `!~* '^[h|a|t]'`
[notIn]?: Literal | readonly OperatorValues<NonNullable<AttributeType>>[]

Example

`[Op.notIn]: [1, 2],` becomes `NOT IN (1, 2)`
[notLike]?: AllowAnyAll<OperatorValues<Extract<AttributeType, string>>>

Example

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

Example

`[Op.notLike]: { [Op.any]: ['cat', 'hat']}` becomes `NOT LIKE ANY (ARRAY['cat', 'hat'])`
[notRegexp]?: AllowAnyAll<OperatorValues<Extract<AttributeType, string>>>

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<RangeType>
    ? Rangable<RangeType>
    : AttributeType extends any[]
        ? StaticValues<NonNullable<AttributeType>>
        : never)>

PG array & range 'overlaps' operator

Example

`[Op.overlap]: [1, 2]` becomes `&& [1, 2]`
[regexp]?: AllowAnyAll<OperatorValues<Extract<AttributeType, string>>>

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.

Generated using TypeDoc