Skip to content

IsotopeSelect.where

Add a WHERE clause to a SQL query expression

Signature

IsotopeSelect<T>.where(
  condition: string,
  ...args: any[]
): this

Parameters

condition

Condition expression — an expression can contain various placeholders, namely ? which can be passed as variadic arguments. See the official AWS documentation on the SimpleDB query language in order to learn about the types of expressions that can be used in SQL queries or see this section for some usage examples. A brief overview:

...args

Placeholder arguments which are replaced in the condition expression — note that string values are auto-quoted if the encoding is set to "json". If the condition contains a LIKE expression, string values must include a % sign which is not quoted, so JSON values can also be searched.

Example

=

`` ts tab="JSON encoding" // SELECT * FROMdomainWHERE (key= '"value"') isotope.getQueryBuilder() .where("key` = ?", "value") .toString()

``` ts tab="Text encoding"
// SELECT * FROM `domain` WHERE (`key` = 'value')
isotope.getQueryBuilder()
  .where("`key` = ?", "value")
  .toString()

LIKE

`` ts tab="JSON encoding" // SELECT * FROMdomainWHERE (keyLIKE '"value%') isotope.getQueryBuilder() .where("key` LIKE ?", "value%") .toString()

``` ts tab="Text encoding"
// SELECT * FROM `domain` WHERE (`key` LIKE 'value%')
isotope.getQueryBuilder()
  .where("`key` LIKE ?", "value%")
  .toString()

AND

`` ts tab="JSON encoding" // SELECT * FROMdomainWHERE (key>= '1') AND (key<= '2') isotope.getQueryBuilder() .where("key>= ?", 1) .where("key` <= ?", 2) .toString()

``` ts tab="Text encoding"
// SELECT * FROM `domain` WHERE (`key` >= '1') AND (`key` <= '2')
isotope.getQueryBuilder()
  .where("`key` >= ?", 1)
  .where("`key` <= ?", 2)
  .toString()

OR

`` ts tab="JSON encoding" // SELECT * FROMdomainWHERE (key= '1' ORkey= '2') isotope.getQueryBuilder() .where("key= ? ORkey` = ?", 1, 2) .toString()

``` ts tab="Text encoding"
// SELECT * FROM `domain` WHERE (`key` = '1' OR `key` = '2')
isotope.getQueryBuilder()
  .where("`key` = ? OR `key` = ?", 1, 2)
  .toString()