UNPKG

mongoose-transact-utils

Version:
10 lines (9 loc) 449 B
import { ClientSession } from 'mongoose'; export declare type MutationCallback<T> = (session: ClientSession) => Promise<T>; /** * Runs the provided `mutations` callback within a transaction and commits the changes to the DB * only when it has run successfully. * * @param mutations A callback which does DB writes and reads using the session. */ export declare function runInTransaction<T>(mutations: MutationCallback<T>): Promise<T>;