Skip to content

Commit 83e6785

Browse files
clarify that equals is order aware (#6780)
Co-authored-by: Aidan McAlister <[email protected]>
1 parent 5fb0175 commit 83e6785

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

content/200-orm/500-reference/050-prisma-client-reference.mdx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3607,20 +3607,13 @@ const result = await prisma.user.update({
36073607

36083608
## Filter conditions and operators
36093609

3610-
<Admonition type="info">
3611-
3612-
- From version 4.3.0, you can also use these operators to compare _fields_ in the same model [with the `<model>.fields` property](#compare-columns-in-the-same-table).
3613-
- In versions before 4.3.0, you can compare fields in the same model [with raw queries](/orm/more/help-and-troubleshooting/comparing-columns-through-raw-queries).
3614-
3615-
</Admonition>
3616-
36173610
### `equals`
36183611

36193612
Value equals `n`.
36203613

36213614
#### Examples
36223615

3623-
##### Return all users where `name` equals `"Eleanor"`
3616+
**Return all users where `name` equals `"Eleanor"`**
36243617

36253618
```ts
36263619
const result = await prisma.user.findMany({
@@ -3642,7 +3635,7 @@ const result = await prisma.user.findMany({
36423635
});
36433636
```
36443637

3645-
##### Return all products with a quantity lower than the "warn quantity" threshold
3638+
**Return all products with a quantity lower than the "warn quantity" threshold**
36463639

36473640
This example compares fields of the same model which is available as of version 4.3.0.
36483641

@@ -3651,7 +3644,23 @@ const productsWithLowQuantity = await prisma.product.findMany({
36513644
where: {
36523645
quantity: {
36533646
lte: prisma.product.fields.warnQuantity
3654-
}
3647+
},
3648+
},
3649+
});
3650+
```
3651+
3652+
**Return all users that have blue and green as their favorite colors**
3653+
3654+
This example finds users that have set their `favoriteColors` field to `['blue', 'green']`.
3655+
3656+
Note that when using `equals`, order of elements matters. That is to say `['blue', 'green']` is **not** equal to `['green', 'blue']`
3657+
3658+
```ts
3659+
const favoriteColorFriends = await prisma.user.findMany({
3660+
where: {
3661+
favoriteColors: {
3662+
equals: ['blue', 'green'],
3663+
},
36553664
},
36563665
});
36573666
```

0 commit comments

Comments
 (0)