8000 docs(uuid): use native uuid method · adonisjs/lucid.adonisjs.com@8f7eb55 · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8f7eb55

Browse files
committed
docs(uuid): use native uuid method
1 parent f604282 commit 8f7eb55

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

content/docs/models/introduction.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ export default class User extends BaseModel {
235235
Set this option to `true` if you don't rely on the database to generate the primary keys. For example, You want to self-assign `uuid` to the new rows.
236236

237237
```ts
238-
import uuid from 'uuid/v4'
238+
import { randomUUID } from 'node:crypto'
239239
import { BaseModel, beforeCreate } from '@adonisjs/lucid/orm'
240240

241241
export default class User extends BaseModel {
@@ -246,7 +246,7 @@ export default class User extends BaseModel {
246246

247247
@beforeCreate()
248248
static assignUuid(user: User) {
249-
user.id = uuid()
249+
user.id = randomUUID()
250250
}
251251
}
252252
```

content/docs/models/model_factories.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,12 @@ Factory.stubId((counter, model) => {
225225
You can make use of the `makeStubbed` hook to customize the id generation behavior for an individual factory.
226226

227227
```ts
228+
import { randomUUID } from 'node:crypto'
229+
228230
Factory.define(Post, () => {
229231
return {}
230232
}).before('makeStubbed', (_, model) => {
231-
model.id = uuid.v4()
233+
model.id = randomUUID()
232234
})
233235
```
234236

0 commit comments

Comments
 (0)
0