R/edit-lock.R

Defines functions unlock lock

Documented in lock unlock

#' Lock and unlock a dataset for editing
#'
#' Crunch allows a single active editor. If you have edit privileges but are
#' not currently editing the dataset, you must unlock the dataset before
#' making changes. You may then lock the dataset when you're done editing.
#' @param dataset a `CrunchDataset`
#' @return `dataset`, invisibly, after having set the current editor.
#' @export
lock <- function(dataset) {
    crPATCH(self(dataset), body = toJSON(list(current_editor = NULL)))
    invisible(dataset)
}

#' @rdname lock
#' @export
unlock <- function(dataset) {
    crPATCH(self(dataset), body = toJSON(list(current_editor = userURL())))
    invisible(dataset)
}

Try the crunch package in your browser

Any scripts or data that you put into this service are public.

crunch documentation built on Aug. 31, 2023, 1:07 a.m.