Sequelize Query info
Overview
The SequelizeQuery argument can be used to specify content selections on queries providing limit
, offset
, order
, group
,where
and include
parameters. As its name implies, it follows the same syntax and implementation as Sequelize ORM
Limit & Offset
Field | Description | Documentation link |
---|---|---|
limit | Limit results to this number of items | https://sequelize.org/docs/v6/core-concepts/model-querying-basics/#limits-and-pagination |
offset | Start results after this number of items | https://sequelize.org/docs/v6/core-concepts/model-querying-basics/#limits-and-pagination |
Ordering & Grouping
Field | Description | Documentation link |
---|---|---|
order | Order results | https://sequelize.org/docs/v6/core-concepts/model-querying-basics/#ordering |
group | Group results | https://sequelize.org/docs/v6/core-concepts/model-querying-basics/#grouping |
Where & Includes
Field | Description | Documentation link |
---|---|---|
where | Conditionally include results | https://sequelize.org/docs/v6/core-concepts/model-querying-basics/#applying-where-clauses |
includes | Conditionally eagerly fetch associated results | https://sequelize.org/docs/v6/advanced-association-concepts/eager-loading |
Supported operators
The following operators are supported for advanced where
or includes
settings
Operator | Description |
---|---|
$gt | Greater than |
$gte | Greater than or equal to |
$lt | Less than |
$lte | Less than or equal to |
$not | Not |
$overlap | Database array and provided array have values that overlap (in common) |
$contains | Database array contains provided element or array |
$and | And |
$or | Or |
$like | Case sensitive pattern matching |
$iLike | Case insensitive pattern matching |
$notLike | Case sensitive exclusive pattern matching |
$notILike | Case insensitive exclusive pattern matching |
Advanced reading
- Applying WHERE clauses - https://sequelize.org/docs/v6/core-concepts/model-querying-basics/#applying-where-clauses
- Operators - https://sequelize.org/docs/v6/core-concepts/model-querying-basics/#operators
- Operator Aliases -https://sequelize.org/docs/v6/core-concepts/model-querying-basics/#deprecated-operator-aliases
- Complex where clauses at the top-level - https://sequelize.org/docs/v6/advanced-association-concepts/eager-loading/#complex-where-clauses-at-the-top-level
Operator operation building
Due to the requirement for escape characters becoming very fiddly at larger scales it is advised that you write your advanced where
queries as javascript objects and double stringify them to get the escape characters. You can also use the tool below to do this for you.
Operator example
This example searches for posts that have start the day
anywhere in either the title
or description
(Where
section) and who's post parent includes one of the specified meditation
categories (Includes
section).