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
Mykhailo
Mykhailo11mo ago
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 query
Drizzle ORM - Insert
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Piers
PiersOP11mo ago
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 else
Mykhailo
Mykhailo11mo ago
I think you can use it only if you deal with auto increment primary key
Piers
PiersOP11mo ago
Ah that makes more sense. Thank you
Want results from more Discord servers?
Add your server