call<R> method
Future<R>
call<R>(
- Future<
R> fn(- T tx
- int maxWait = 2000,
- int timeout = 5000,
- TransactionIsolationLevel? isolationLevel,
Interactive transactions.
Example
prisma.$transaction((prisma) async {
final user = await prisma.user.create(...);
await prisma.user.update(...);
return user;
});
Implementation
Future<R> call<R>(
Future<R> Function(T tx) fn, {
int maxWait = 2000,
int timeout = 5000,
TransactionIsolationLevel? isolationLevel,
}) async {
final client = await start(
maxWait: maxWait,
timeout: timeout,
isolationLevel: isolationLevel,
);
try {
final result = await fn(client);
await commit();
return result;
} catch (e) {
await rollback();
rethrow;
}
}