You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to pass along a transaction to a variety of handler/wrapper functions, for example for checking application-level permissions.
I want those functions to be properly typed.
What's the least-verbose way to forward the type of the transaction to each of the functions?
interface IWhatever ...;
class Whatever ...;
const someData: IWhatever = ...;
const result = await db.transaction(async (tx: WhatGoesHere): Promise<Whatever> => {
return checkingFunction(tx, someData);
});
function checkingFunction(tx: WhatGoesHere, someData: IWhatever): Promise<Whatever> {
... do stuff ...
return aWhatever;
}
Currently, for WhatGoesHere I have:
type Txn = PgTransaction<PostgresJsQueryResultHKT, Record<string, unknown>, ExtractTablesWithRelations<Record<string, unknown>>>;
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I want to pass along a transaction to a variety of handler/wrapper functions, for example for checking application-level permissions.
I want those functions to be properly typed.
What's the least-verbose way to forward the type of the transaction to each of the functions?
Currently, for
WhatGoesHere
I have:Beta Was this translation helpful? Give feedback.
All reactions