How do you use batch API with local development

If you use Neon, but do local development using postgres-js in docker, how can you write code that uses batch API? it seems like there should be some sort of shim that runs batches as a transaction under the hood to allow the same drizzle code to run for drivers that don't support batches.
2 Replies
Dan
Dan10mo ago
not at the moment, batch is not implemented in all drivers
jakeleventhal
jakeleventhalOP10mo ago
for postgres-js for instance, wouldnt batch implementation just be something like this:
// user code:
await db.batch(statements satisfies Array<SQL>);

// under the hood code:
await db.execute(sql`
BEGIN TRANSACTION
${statements.join(';\n')}
COMMIT TRANSACTION
`);
// user code:
await db.batch(statements satisfies Array<SQL>);

// under the hood code:
await db.execute(sql`
BEGIN TRANSACTION
${statements.join(';\n')}
COMMIT TRANSACTION
`);
Want results from more Discord servers?
Add your server