Function where

  • A way of specifying "attr = condition". Can be used as a replacement for the POJO syntax (e.g. where: { name: 'Lily' }) when you need to compare a column that the POJO syntax cannot represent.

    Example

    // Using an attribute as the left operand.
    // Equal to: WHERE first_name = 'Lily'
    where(User.rawAttributes.firstName, Op.eq, 'Lily');

    Example

    // Using a column name as the left operand.
    // Equal to: WHERE first_name = 'Lily'
    where(col('first_name'), Op.eq, 'Lily');

    Example

    // Using a SQL function on the left operand.
    // Equal to: WHERE LOWER(first_name) = 'lily'
    where(fn('LOWER', col('first_name')), Op.eq, 'lily');

    Example

    // Using raw SQL as the left operand. // Equal to: WHERE 'Lily' = 'Lily' where(literal('Lily'), Op.eq, 'Lily');

    Type Parameters

    Parameters

    • leftOperand: WhereLeftOperand | Where<typeof eq>

      The left side of the comparison.

      • A value taken from YourModel.rawAttributes, to reference an attribute. The attribute must be defined in your model definition.
      • A Literal (using literal)
      • A SQL Function (using fn)
      • A Column name (using col) Note that simple strings to reference an attribute are not supported. You can use the POJO syntax instead.
    • operator: OpSymbol

      The comparison operator to use. If unspecified, defaults to Op.eq.

    • rightOperand: WhereOperators<any>[OpSymbol]

      The right side of the comparison. Its value depends on the used operator. See WhereOperators for information about what value is valid for each operator.

    Returns Where

  • Parameters

    • leftOperand: any
    • operator: string
    • rightOperand: any

    Returns Where

  • Parameters

    Returns Where

Generated using TypeDoc