add a prefix to UUID?
I am wondering if there is a functionality where I can add a custom prefix the uuid's. These uuids would be used as a pirmary key in my case.
The end result would be something like this:
product_9B4F49D6F35C49FEA0dCC579A8ED4755
7 Replies
Is the idea is to distinguish between ids from different tables?
yes and for the users of api to understand what the id is pointing to
You can use
crypo.randomUUID()
to generate a UUID in side drizzle's .defaultFn()
method like this:
thank you so much :D
This is an application-level default, not a db-level default. If you tried to insert in an SQL client, the default would not be applied.
yes there probably wont be any operations made using sql client
For a schema level implementation, you could probably get it working with something along the lines of