#' @title
#' Transaction Control Language (TCL)
#'
#' @description
#' Transaction control allows changes in the data via [`dml`] or `ddl` to
#' be batched together in an "all-or-nothing" fashion.
#'
#' @param object (obj) whose transactions are to be controlled.
#' @param ... (arg) passed to underlying functions
#'
#' @family Database Operations
#' @name tcl
NULL
#' @describeIn tcl Ensures that a transaction is in place; no-op if already
#' in a transaction
#' @export
transact <- function(object, ...) {
UseMethod("transact")
}
#' @describeIn tcl Starts a transaction; throws error if already in transaction
#' @export
begin <- function(object, ...) {
assert_false(in_transaction(object))
UseMethod("begin")
}
#' @describeIn tcl Commits the changes into the database
#' @export
commit <- function(object, ...) {
assert_true(in_transaction(object))
UseMethod("commit")
}
#' @describeIn tcl Rolls back the transaction and cancels changes to the data
#' @export
rollback <- function(object, ...) {
assert_true(in_transaction(object))
UseMethod("rollback")
}
#' @describeIn tcl Checks if the connection is in a transaction
#' @export
in_transaction <- function(object, ...) {
UseMethod("in_transaction")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.