Companion

Functions

Link copied to clipboard
context(_: Raise<ErrorSpec>)
inline fun <T> db(block: () -> DbResult<T>): T

Executes a database operation within a safe context, raising errors as specified by the ErrorSpec interface.

Link copied to clipboard
context(_: Raise<ErrorSpec>)
inline fun <T> dbCatching(block: () -> DbResult<T>): Either<DatabaseError, T>

Executes a given database operation block, catching any potential errors and mapping them to a consistent error format. This method ensures robust error handling and encapsulates the result of the database operation in an Either type.

Link copied to clipboard
context(ec: ExecContext)
inline suspend fun <R> DatabaseService.withTransaction(crossinline block: context(Transaction) suspend () -> R): R

Executes a transactional context for a given operation. The operation is wrapped in a database transaction and executed while tracking its duration using OpenTelemetry.