DB and Transaction types

I am creating a drizzle instance like this

import { drizzle } from 'drizzle-orm/postgres-js';
const db = drizzle(client, {
  schema,
  casing: 'snake_case',
  logger: false
});


Now I want to allow for functions to pass in a transaction or drizzle db

async function updateFoo(params: {
    tx?: Transaction | DB,
  }) : Promise<void> {
const { tx = db } = params;


I am somewhat lost on the types.

Or is there a better way of allowing for optional transactions in a function?
Was this page helpful?