types for database/transaction

Hey, I have this function:

export const userRelationExists = async (
    ...,
    database
) => {
    return database.query.users.findFirst({
        ...
    });
}


You can see, that I get a database as variable. That can either be a default postgres database (easy to type) or it can be a transaction (how to type). I would like to know how to type them correctly, so I can use users in this case?

I could do something like this:
    database: PgTransaction<any, any, any> | PgDatabase<any>

But then I can access users via database.query.users :/
Was this page helpful?