Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions content/_partials/query-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ The syntax for using a function is `function(field)`.
| `week` | Extract the week from a datetime/date/timestamp field |
| `day` | Extract the day from a datetime/date/timestamp field |
| `weekday` | Extract the weekday from a datetime/date/timestamp field |
| `hour` | Extract the hour from a datetime/date/timestamp field |
| `minute` | Extract the minute from a datetime/date/timestamp field |
| `second` | Extract the second from a datetime/date/timestamp field |
| `hour` | Extract the hour from a datetime/time/timestamp field |
| `minute` | Extract the minute from a datetime/time/timestamp field |
| `second` | Extract the second from a datetime/time/timestamp field |
| `count` | Extract the number of items from a JSON array or relational field |
| `json` | Extract a specific value from a JSON field using path notation |
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ interface CollectionA {
}
```

There are currently 3 literal types that can be applied. The first 2 are both used to apply the `count(field)`
There are currently 5 literal types that can be applied. The first 2 are both used to apply the `count(field)`
array function in the `filter`/`field` auto-complete suggestions, these are the
`'json'` and `'csv'` string literal types. The `'datetime'` string literal type which is used to apply all
datetime functions in the `filter`/`field` auto-complete suggestions.
`'json'` and `'csv'` string literal types. The `'datetime'`, `'date'`, and `'time'` string literal types which are used to apply related functions in the `filter`/`field` auto-complete suggestions.

```ts
interface CollectionA {
Expand All @@ -96,13 +95,15 @@ interface CollectionA {
tags: 'csv'; // [!code ++]
json_field: 'json'; // [!code ++]
date_created: 'datetime'; // [!code ++]
start_time: 'time'; // [!code ++]
event_date: 'date'; // [!code ++]
}
```

In the output types these string literals will get resolved to their appropriate types:

- `'csv'` resolves to `string[]`
- `'datetime'` resolves to `string`
- `'datetime'`, `'date'`, and `'time'` resolve to `string`
- `'json'` resolves to [`JsonValue`](https://github.com/directus/directus/blob/main/sdk/src/types/output.ts#L105)

::callout{icon="material-symbols:warning-rounded" color="warning"}
Expand Down