b3z
b3z
DTDrizzle Team
Created by b3z on 5/14/2023 in #help
insertID not returned correctly when using custom UUID
export const users = mysqlTable("users", {
id: varchar("id", { length: 36 })
.primaryKey()
.default(sql`(uuid())`)
.notNull(),
email: varchar("email", { length: 255 }).notNull(),
profileImageUrl: varchar("profile_image_url", { length: 255 }),
name: varchar("name", { length: 255 }).notNull(),
});
export const users = mysqlTable("users", {
id: varchar("id", { length: 36 })
.primaryKey()
.default(sql`(uuid())`)
.notNull(),
email: varchar("email", { length: 255 }).notNull(),
profileImageUrl: varchar("profile_image_url", { length: 255 }),
name: varchar("name", { length: 255 }).notNull(),
});
I have a schema where I have set the ID to be a uuid, this works fine and inserts give me the correct ids. On insert I want to get the ID of the inserted record so I can redirect to the correct page, which I thought would be available on insertId but what I get returned from there is just a number. Is there another way to get the actual id of the inserted record?
5 replies