Skip to content
Discussion options

You must be logged in to vote

Hey @edikurniawan-dev! 👋🏻

You can approach this the same way you would in any other codebase. AdonisJS doesn't introduce anything special in this regard, it just offers more built-in features when needed.

If you want to use UUIDs, simply install the uuid package from npm and use it where appropriate. For example, if you want to use a UUID as the primary key in a model, you can either define a mixin (to keep your code DRY) or use a @beforeCreate hook directly inside your model.

Here’s an example using a mixin:

import { v7 as randomUUID } from 'uuid';
import { beforeCreate, column } from '@adonisjs/lucid/orm';
import type { BaseModel } from '@adonisjs/lucid/orm';
import type { NormalizeCons…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@edikurniawan-dev
Comment options

Answer selected by edikurniawan-dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants