Skip to content

Commit 432f41d

Browse files
authored
fix: Add documentation for uuidv7 default option. (serverpod#277)
1 parent 605d74e commit 432f41d

1 file changed

Lines changed: 52 additions & 50 deletions

File tree

docs/06-concepts/02-models.md

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ This means that `defaultPersist` only comes into play when the model does not pr
195195

196196
#### Boolean
197197

198-
| Type | Keyword | Description |
199-
|-----------------|--------------------|-------------------------------------------------------|
200-
| **Boolean** | `true` or `false` | Sets the field to a boolean value, either `true` or `false`. |
198+
| Type | Keyword | Description |
199+
| ----------- | ----------------- | ------------------------------------------------------------ |
200+
| **Boolean** | `true` or `false` | Sets the field to a boolean value, either `true` or `false`. |
201201

202202
**Example:**
203203

@@ -207,10 +207,10 @@ boolDefault: bool, default=true
207207

208208
#### DateTime
209209

210-
| Type | Keyword | Description |
211-
|-------------------------|---------------|--------------------------------------------------------------|
212-
| **Current Date and Time** | `now` | Sets the field to the current date and time. |
213-
| **Specific UTC DateTime** | UTC DateTime string in the format `yyyy-MM-dd'T'HH:mm:ss.SSS'Z'` | Sets the field to a specific date and time. |
210+
| Type | Keyword | Description |
211+
| ------------------------- | ---------------------------------------------------------------- | -------------------------------------------- |
212+
| **Current Date and Time** | `now` | Sets the field to the current date and time. |
213+
| **Specific UTC DateTime** | UTC DateTime string in the format `yyyy-MM-dd'T'HH:mm:ss.SSS'Z'` | Sets the field to a specific date and time. |
214214

215215
**Example:**
216216

@@ -221,9 +221,9 @@ dateTimeDefaultUtc: DateTime, default=2024-05-01T22:00:00.000Z
221221

222222
#### Double
223223

224-
| Type | Keyword | Description |
225-
|-----------------|--------------------|-------------------------------------------------------|
226-
| **Double** | Any double value | Sets the field to a specific double value. |
224+
| Type | Keyword | Description |
225+
| ---------- | ---------------- | ------------------------------------------ |
226+
| **Double** | Any double value | Sets the field to a specific double value. |
227227

228228
**Example:**
229229

@@ -233,8 +233,8 @@ doubleDefault: double, default=10.5
233233

234234
#### Duration
235235

236-
| Type | Keyword | Description |
237-
|---------------------|---------------------|-----------------------------------------------------------------------------|
236+
| Type | Keyword | Description |
237+
| --------------------- | -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
238238
| **Specific Duration** | A valid duration in the format `Xd Xh Xmin Xs Xms` | Sets the field to a specific duration value. For example, `1d 2h 10min 30s 100ms` represents 1 day, 2 hours, 10 minutes, 30 seconds, and 100 milliseconds. |
239239

240240
**Example:**
@@ -245,9 +245,9 @@ durationDefault: Duration, default=1d 2h 10min 30s 100ms
245245

246246
#### Enum
247247

248-
| Type | Keyword | Description |
249-
|-----------------|--------------------|-------------------------------------------------------|
250-
| **Enum** | Any valid enum value | Sets the field to a specific enum value. |
248+
| Type | Keyword | Description |
249+
| -------- | -------------------- | ---------------------------------------- |
250+
| **Enum** | Any valid enum value | Sets the field to a specific enum value. |
251251

252252
**Example:**
253253

@@ -282,9 +282,9 @@ In this example:
282282

283283
#### Integer
284284

285-
| Type | Keyword | Description |
286-
|-----------------|--------------------|-------------------------------------------------------|
287-
| **Integer** | Any integer value | Sets the field to a specific integer value. |
285+
| Type | Keyword | Description |
286+
| ----------- | ----------------- | ------------------------------------------- |
287+
| **Integer** | Any integer value | Sets the field to a specific integer value. |
288288

289289
**Example:**
290290

@@ -294,9 +294,9 @@ intDefault: int, default=10
294294

295295
#### String
296296

297-
| Type | Keyword | Description |
298-
|-----------------|--------------------|-------------------------------------------------------|
299-
| **String** | Any string value | Sets the field to a specific string value. |
297+
| Type | Keyword | Description |
298+
| ---------- | ---------------- | ------------------------------------------ |
299+
| **String** | Any string value | Sets the field to a specific string value. |
300300

301301
**Example:**
302302

@@ -306,16 +306,18 @@ stringDefault: String, default='This is a string'
306306

307307
#### UuidValue
308308

309-
| Type | Keyword | Description |
310-
|--------------------|--------------------|-------------------------------------------------------|
311-
| **Random UUID** | `random` | Generates a random UUID. On the Dart side, `Uuid().v4obj()` is used. On the database side, `gen_random_uuid()` is used. |
312-
| **UUID String** | A valid UUID version 4 string | Assigns a specific UUID to the field. |
309+
| Type | Keyword | Description |
310+
| ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
311+
| **Random UUID** | `random` | Generates a random UUID. On the Dart side, `Uuid().v4obj()` is used. On the database side, `gen_random_uuid()` is used. |
312+
| **Random UUIDv7** | `random_v7` | Generates a random UUIDv7. On the Dart side, `Uuid().v7obj()` is used. On the database side, a generated `gen_random_uuid_v7()` function is used. |
313+
| **UUID String** | Valid UUID in the format 'xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx' where M is the UUID version field. The upper two or three bits of digit N encode the variant. E.g. '550e8400-e29b-41d4-a716-446655440000' | Assigns a specific UUID to the field. |
313314

314315
**Example:**
315316

316317
```yaml
317318
uuidDefaultRandom: UuidValue, default=random
318319
uuidDefaultUuid: UuidValue, default='550e8400-e29b-41d4-a716-446655440000'
320+
uuidDefaultRandomUuidV7: UuidValue, default=random_v7
319321
```
320322

321323
### Example
@@ -342,28 +344,28 @@ fields:
342344

343345
## Keywords
344346

345-
|**Keyword**|Note|[class](#class)|[exception](#exception)|[enum](#enum)|
346-
|---|---|:---:|:---:|:---:|
347-
|[**values**](#enum)|A special key for enums with a list of all enum values. |||✅|
348-
|[**serialized**](#enum)|Sets the mode enums are serialized in |||✅|
349-
|[**serverOnly**](#limiting-visibility-of-a-generated-class)|Boolean flag if code generator only should create the code for the server. |✅|✅|✅|
350-
|[**table**](database/models)|A name for the database table, enables generation of database code. |✅|||
351-
|[**managedMigration**](database/migrations#opt-out-of-migrations)|A boolean flag to opt out of the database migration system. |✅|||
352-
|[**fields**](#class)|All fields in the generated class should be listed here. |✅|✅||
353-
|[**type (fields)**](#class)|Denotes the data type for a field. |✅|✅||
354-
|[**scope**](#limiting-visibility-of-a-generated-class)|Denotes the scope for a field. |✅|||
355-
|[**persist**](database/models)|A boolean flag if the data should be stored in the database or not can be negated with `!persist` |✅|||
356-
|[**relation**](database/relations/one-to-one)|Sets a relation between model files, requires a table name to be set. |✅|||
357-
|[**name**](database/relations/one-to-one#bidirectional-relations)|Give a name to a relation to pair them. |✅|||
358-
|[**parent**](database/relations/one-to-one#with-an-id-field)|Sets the parent table on a relation. |✅|||
359-
|[**field**](database/relations/one-to-one#custom-foreign-key-field)|A manual specified foreign key field. |✅|||
360-
|[**onUpdate**](database/relations/referential-actions)|Set the referential actions when updating data in the database. |✅|||
361-
|[**onDelete**](database/relations/referential-actions)|Set the referential actions when deleting data in the database. |✅|||
362-
|[**optional**](database/relations/one-to-one#optional-relation)|A boolean flag to make a relation optional. |✅|||
363-
|[**indexes**](database/indexing)|Create indexes on your fields / columns. |✅|||
364-
|[**fields (index)**](database/indexing)|List the fields to create the indexes on. |✅|||
365-
|[**type (index)**](database/indexing)|The type of index to create. |✅|||
366-
|[**unique**](database/indexing)|Boolean flag to make the entries unique in the database. |✅|||
367-
|[**default**](#default-values)|Sets the default value for both the model and the database. This keyword cannot be used with **relation**. |✅|||
368-
|[**defaultModel**](#default-values)|Sets the default value for the model side. This keyword cannot be used with **relation**. |✅|||
369-
|[**defaultPersist**](#default-values)|Sets the default value for the database side. This keyword cannot be used with **relation** and **!persist**. |✅|||
347+
| **Keyword** | Note | [class](#class) | [exception](#exception) | [enum](#enum) |
348+
| ------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | :-------------: | :---------------------: | :-----------: |
349+
| [**values**](#enum) | A special key for enums with a list of all enum values. | | | ✅ |
350+
| [**serialized**](#enum) | Sets the mode enums are serialized in | | | ✅ |
351+
| [**serverOnly**](#limiting-visibility-of-a-generated-class) | Boolean flag if code generator only should create the code for the server. | ✅ | ✅ | ✅ |
352+
| [**table**](database/models) | A name for the database table, enables generation of database code. | ✅ | | |
353+
| [**managedMigration**](database/migrations#opt-out-of-migrations) | A boolean flag to opt out of the database migration system. | ✅ | | |
354+
| [**fields**](#class) | All fields in the generated class should be listed here. | ✅ | ✅ | |
355+
| [**type (fields)**](#class) | Denotes the data type for a field. | ✅ | ✅ | |
356+
| [**scope**](#limiting-visibility-of-a-generated-class) | Denotes the scope for a field. | ✅ | | |
357+
| [**persist**](database/models) | A boolean flag if the data should be stored in the database or not can be negated with `!persist` | ✅ | | |
358+
| [**relation**](database/relations/one-to-one) | Sets a relation between model files, requires a table name to be set. | ✅ | | |
359+
| [**name**](database/relations/one-to-one#bidirectional-relations) | Give a name to a relation to pair them. | ✅ | | |
360+
| [**parent**](database/relations/one-to-one#with-an-id-field) | Sets the parent table on a relation. | ✅ | | |
361+
| [**field**](database/relations/one-to-one#custom-foreign-key-field) | A manual specified foreign key field. | ✅ | | |
362+
| [**onUpdate**](database/relations/referential-actions) | Set the referential actions when updating data in the database. | ✅ | | |
363+
| [**onDelete**](database/relations/referential-actions) | Set the referential actions when deleting data in the database. | ✅ | | |
364+
| [**optional**](database/relations/one-to-one#optional-relation) | A boolean flag to make a relation optional. | ✅ | | |
365+
| [**indexes**](database/indexing) | Create indexes on your fields / columns. | ✅ | | |
366+
| [**fields (index)**](database/indexing) | List the fields to create the indexes on. | ✅ | | |
367+
| [**type (index)**](database/indexing) | The type of index to create. | ✅ | | |
368+
| [**unique**](database/indexing) | Boolean flag to make the entries unique in the database. | ✅ | | |
369+
| [**default**](#default-values) | Sets the default value for both the model and the database. This keyword cannot be used with **relation**. | | | |
370+
| [**defaultModel**](#default-values) | Sets the default value for the model side. This keyword cannot be used with **relation**. | | | |
371+
| [**defaultPersist**](#default-values) | Sets the default value for the database side. This keyword cannot be used with **relation** and **!persist**. | | | |

0 commit comments

Comments
 (0)