drizzle-orm
drizzle-orm copied to clipboard
[FEATURE]: Return `changes/lastInsertRowid` as opposed to `void` when using Bun Sqlite driver
Describe what you want
As of Bun 1.1.14 db.insert returns a result in the form:
{ changes: number, lastInsertRowid: number }
(see https://bun.sh/blog/bun-v1.1.14#track-changes-with-query-run-sql )
However Drizzle db.insert() returns void, causing the following TS error:
Property 'lastInsertRowid' does not exist on type 'void'. in the following example:
const result = db.insert(users).values(user).run();
console.log(result.lastInsertRowid);
A workaround would be:
const result = db.insert(users).values(user).run() as unknown as { changes: number; lastInsertRowid: number };
console.log(result.lastInsertRowid);
It would be great if the return value from the sqlite driver could be passed on so TypeScript understands it.