$contained:[1,2]// <@ [1, 2] (PG array contained by operator)
}
}
})
...
...
@@ -719,35 +715,44 @@ Project.findAll({
### Complex filtering / OR queries
Since `v1.7.0-rc3`, it is possible to do complex where queries with multiple levels of nested AND and OR conditions. In order to do that you can use `Sequelize.or` and `Sequelize.and` and pass an arbitrary amount of arguments to it. Every argument will get transformed into a proper SQL condition and gets joined with the either `AND` or `OR`.
It's possible to do complex where queries with multiple levels of nested AND and OR conditions. In order to do that you can use `$or` and `$and`:
```js
Project.find({
where:Sequelize.and(
{name:'a project'},
Sequelize.or(
where:{
name:'a project',
$or:[
{id:[1,2,3]},
{id:{gt:10}}
)
)
{id:{$gt:10}}
]
}
})
Project.find({
where:{
name:'a project',
id:{
$or:[
[1,2,3],
{$gt:10}
]
}
}
})
```
This code will generate the following query:
Both pieces of code code will generate the following:
```sql
SELECT*
FROM`Projects`
WHERE(
`Projects`.`name`='a project'
`Projects`.`name`='a project'
AND(`Projects`.`id`IN(1,2,3)OR`Projects`.`id`>10)
)
LIMIT1
;
LIMIT1;
```
Notice, that instead of `Sequelize.and` you can also use a plain array which will be treated as `Sequelize.and` if it contains objects or hashes or other complex data types. Furthermore you can use `Sequelize.or` as value for the where clause.
### Manipulating the dataset with limit, offset, order and group
To get more relevant data, you can use limit, offset, order and grouping: