Insert returning and left join

Is it possible to do a leftJoin when returning() on an insert? Pseudo code that do not work (but to show an example of what I want). I.e. I want the user object returned on each splits I insert.
const [splits] = await db.insert(transactionSplitsTable).values(insert_splits).returning().leftJoin(usersTable, eq(usersTable.id, transactionSplitsTable.user_id)
const [splits] = await db.insert(transactionSplitsTable).values(insert_splits).returning().leftJoin(usersTable, eq(usersTable.id, transactionSplitsTable.user_id)
2 Replies
Sillvva
Sillvva6mo ago
returning is not a SELECT query. It's part of the INSERT query. In PostgreSQL you could do an INSERT inside a CTE, but not in SQLite. And even then, drizzle doesn't natively support that.
Tobias
TobiasOP6mo ago
Thank you for the information @Sillvva
Want results from more Discord servers?
Add your server