Type of `tx` when using `db.transactions`

I want to use helper functions within db.transactions but I can't get the type of tx working
so basically i don't know how to type tx in the updateUserNotifications function
const updateUserNotifications = async (
  userId: UpdateUserAttributes["id"],
  notifications: Required<UpdateUserAttributes>["notifications"],
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  tx: any, // TODO: what's the type of this
) => {
  // check if user has a notification settings record
  const userNotificationSettings = await tx.select().from(userNotifications).where(eq(users.id, userId));

  // create user notification settings record if it doesn't exist
  if (!userNotificationSettings.length) {
    await tx.insert(userNotifications).values({
      userId,
      favorites: notifications.favorites,
    });
  }

  await tx.update(userNotifications).set({ favorites: notifications.favorites }).where(eq(users.id, userId));
};

export const updateUser = async (userAttributes: UpdateUserAttributes) => {
  await db.transaction(async (tx) => {
    // update user notification settings
    if (userAttributes.notifications) {
      await updateUserNotifications(userAttributes.id, userAttributes.notifications, tx);
    }
  });
};
Was this page helpful?