Skip to content

Commit c0ad44a

Browse files
feat: Add a ~ operator on expressions to perform NOT expression (serverpod#318)
1 parent dd3f9b1 commit c0ad44a

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

docs/06-concepts/06-database/06-filter.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ Two special characters enables matching against partial entries.
130130
- **`%`** Matching any sequence of character.
131131
- **`_`** Matching any single character.
132132

133-
| String |  Matcher | Is matching |
134-
| ------ | -------- | ----------- |
135-
| abc |  a%  | true |
136-
|  abc | \_b% | true |
137-
| abc | a_c | true |
138-
| abc | b\_ | false |
133+
| String | Matcher | Is matching |
134+
| ------ | ------- | ----------- |
135+
| abc | a% | true |
136+
| abc | \_b% | true |
137+
| abc | a_c | true |
138+
| abc | b\_ | false |
139139

140140
We use like to match against a partial string.
141141

@@ -209,6 +209,28 @@ await User.db.find(
209209

210210
In the example we fetch all users that has a name that starts with A _or_ B.
211211

212+
The `~` operator is used to negate an expression with a `not` operation.
213+
214+
```dart
215+
await User.db.find(
216+
session,
217+
where: (t) => ~t.name.equals('Alice')
218+
);
219+
```
220+
221+
In the example we fetch all users that do _not_ have the name "Alice".
222+
223+
The `~` operator can also be used with more complex expressions:
224+
225+
```dart
226+
await User.db.find(
227+
session,
228+
where: (t) => ~(t.name.like('A%') | t.age > 25)
229+
);
230+
```
231+
232+
In the example we fetch all users that do _not_ have a name starting with "A" _and_ are _not_ older than 25.
233+
212234
### Vector distance operators
213235

214236
All vector field types support specialized distance operations for similarity search. Available vector distance operations:

0 commit comments

Comments
 (0)