不要怂,就是干,撸起袖子干!

Commit 34ff44cf by Mick Hansen

Merge pull request #3380 from calvintwr/master

$not operator docs update.
2 parents 1c10d07e 12b59a46
Showing with 31 additions and 3 deletions
...@@ -689,7 +689,6 @@ Project.findAll({ ...@@ -689,7 +689,6 @@ Project.findAll({
$lt: 10, // id < 10 $lt: 10, // id < 10
$lte: 10, // id $lte: 10, // id
$ne: 20, // id != 20 $ne: 20, // id != 20
$not: 3, // id NOT 3
$between: [6, 10], // BETWEEN 6 AND 10 $between: [6, 10], // BETWEEN 6 AND 10
$notBetween: [11, 15], // NOT BETWEEN 11 AND 15 $notBetween: [11, 15], // NOT BETWEEN 11 AND 15
$in: [1, 2], // IN [1, 2] $in: [1, 2], // IN [1, 2]
...@@ -700,14 +699,17 @@ Project.findAll({ ...@@ -700,14 +699,17 @@ Project.findAll({
$overlap: [1, 2] // && [1, 2] (PG array overlap operator) $overlap: [1, 2] // && [1, 2] (PG array overlap operator)
$contains: [1, 2] // @> [1, 2] (PG array contains operator) $contains: [1, 2] // @> [1, 2] (PG array contains operator)
$contained: [1, 2] // <@ [1, 2] (PG array contained by operator) $contained: [1, 2] // <@ [1, 2] (PG array contained by operator)
},
status: {
$not: false, // status NOT FALSE
} }
} }
}) })
``` ```
### Complex filtering / OR queries ### Complex filtering / OR / NOT queries
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`: It's possible to do complex where queries with multiple levels of nested AND, OR and NOT conditions. In order to do that you can use `$or`, `$and` or `$not`:
```js ```js
Project.find({ Project.find({
...@@ -745,6 +747,32 @@ WHERE ( ...@@ -745,6 +747,32 @@ WHERE (
LIMIT 1; LIMIT 1;
``` ```
`$not` example:
```js
Project.find({
where: {
name: 'a project',
$not: [
{ id: [1,2,3] },
{ array: { $contains: [3,4,5] } }
]
}
});
```
Will generate:
```sql
SELECT *
FROM `Projects`
WHERE (
`Projects`.`name` = 'a project'
AND NOT (`Projects`.`id` IN (1,2,3) OR `Projects`.`array` @> ARRAY[1,2,3]::INTEGER[])
)
LIMIT 1;
```
### Manipulating the dataset with limit&comma; offset&comma; order and group ### Manipulating the dataset with limit&comma; offset&comma; order and group
To get more relevant data&comma; you can use limit&comma; offset&comma; order and grouping&colon; To get more relevant data&comma; you can use limit&comma; offset&comma; order and grouping&colon;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!