Skip to content

Commit fba826a

Browse files
Docs/add string literal for time and date (#612)
* fix: trailing `::` fixes #601 * fix: docs for `'date'` and `'time'` string literal types --------- Co-authored-by: Bryant Gillespie <bryant@directus.io>
1 parent e425865 commit fba826a

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

content/_partials/query-functions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ The syntax for using a function is `function(field)`.
99
| `week` | Extract the week from a datetime/date/timestamp field |
1010
| `day` | Extract the day from a datetime/date/timestamp field |
1111
| `weekday` | Extract the weekday from a datetime/date/timestamp field |
12-
| `hour` | Extract the hour from a datetime/date/timestamp field |
13-
| `minute` | Extract the minute from a datetime/date/timestamp field |
14-
| `second` | Extract the second from a datetime/date/timestamp field |
12+
| `hour` | Extract the hour from a datetime/time/timestamp field |
13+
| `minute` | Extract the minute from a datetime/time/timestamp field |
14+
| `second` | Extract the second from a datetime/time/timestamp field |
1515
| `count` | Extract the number of items from a JSON array or relational field |
1616
| `json` | Extract a specific value from a JSON field using path notation |

content/tutorials/3.tips-and-tricks/advanced-types-with-the-directus-sdk.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,9 @@ interface CollectionA {
8282
}
8383
```
8484

85-
There are currently 3 literal types that can be applied. The first 2 are both used to apply the `count(field)`
85+
There are currently 5 literal types that can be applied. The first 2 are both used to apply the `count(field)`
8686
array function in the `filter`/`field` auto-complete suggestions, these are the
87-
`'json'` and `'csv'` string literal types. The `'datetime'` string literal type which is used to apply all
88-
datetime functions in the `filter`/`field` auto-complete suggestions.
87+
`'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.
8988

9089
```ts
9190
interface CollectionA {
@@ -96,13 +95,15 @@ interface CollectionA {
9695
tags: 'csv'; // [!code ++]
9796
json_field: 'json'; // [!code ++]
9897
date_created: 'datetime'; // [!code ++]
98+
start_time: 'time'; // [!code ++]
99+
event_date: 'date'; // [!code ++]
99100
}
100101
```
101102

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

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

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

0 commit comments

Comments
 (0)