MySQL returned us question
In the docs it says that you can’t get the inserted ID from MySQL but is that because the returned ID isn’t reliable or is there another reason?
4 Replies
Hi, @Piers! Am I right that you mean
.returning()
in insert
query?
https://orm.drizzle.team/docs/insert#insert-returning
In MySQL there is no returning
clause, that's why you can't return inserted ID with insert
queryDrizzle ORM - Insert
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Yes that’s what I meant.
If I do
const row = await db.insert…
and then console.log(row)
there is the insertId
property returned (I think that’s the name, I’m on my phone so not 100% sure).
I don’t care whether Drizzle handles I because can, but if the reason for not handling it is because it’s not reliable then fair enough.
So if it’s not reliable then I shouldn’t be using it and I need to find something elseI think you can use it only if you deal with auto increment primary key
Ah that makes more sense. Thank you