How do I get insertId from table using cuid2
I want to insert data using a relations, but mysql doesn't support returning(). so i was using insertId, but it doesn't work with custom id like cuid. What should i do
5 Replies
I did some research and I think this is the way the database works, there is no solution.
Save it as a variable before the first insert?
I don't know what you're trying to say. I want to get the auto generated cuid2 by drizzle of the column that I insert.
cuid2 is running in your application, not in your database, right? So just run it before the first insert and save the output to a variable
https://orm.drizzle.team/docs/column-types/mysql#default-value
no, cuid2 runing in my database
Drizzle ORM - next gen TypeScript ORM
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.