
Remove content from the connector
Source:R/cnt_generics.R
, R/dbi_methods.R
, R/fs_methods.R
, and 1 more
remove_cnt.Rd
Generic implementing of how to remove content from different connectors:
ConnectorDBI: Uses
DBI::dbRemoveTable()
to remove the table from a DBI connection.
ConnectorFS: Uses
fs::file_delete()
to delete the file.
ConnectorLogger: Logs the remove operation and calls the underlying connector method.
Usage
remove_cnt(connector_object, name, ...)
# S3 method for class 'ConnectorDBI'
remove_cnt(connector_object, name, ...)
# S3 method for class 'ConnectorFS'
remove_cnt(connector_object, name, ...)
# S3 method for class 'ConnectorLogger'
remove_cnt(connector_object, name, ...)
Value
invisible connector_object.
Examples
# Remove table in a DBI database
cnt <- connector_dbi(RSQLite::SQLite())
cnt |>
write_cnt(iris, "iris") |>
list_content_cnt()
#> [1] "iris"
cnt |>
remove_cnt("iris") |>
list_content_cnt()
#> character(0)
# Remove a file from the file storage
folder <- withr::local_tempdir("test", .local_envir = .GlobalEnv)
cnt <- connector_fs(folder)
cnt |>
write_cnt("this is an example", "example.txt")
cnt |>
list_content_cnt(pattern = "example.txt")
#> [1] "example.txt"
cnt |>
read_cnt("example.txt")
#> → Found one file: /tmp/Rtmpp1dzyw/test1ebe7c09f7c7/example.txt
#> [1] "this is an example"
cnt |>
remove_cnt("example.txt")
cnt |>
list_content_cnt(pattern = "example.txt")
#> character(0)
# Add logging to a connector and remove content
folder <- withr::local_tempdir("test", .local_envir = .GlobalEnv)
cnt <- connectors(data = connector_fs(folder)) |> add_logs()
cnt$data |>
write_cnt(iris, "iris.csv")
#> {"time":"2025-08-20 06:16:06","type":"write","file":"iris.csv @ /tmp/Rtmpp1dzyw/test1ebe3ed83466"}
cnt$data |>
remove_cnt("iris.csv")
#> {"time":"2025-08-20 06:16:06","type":"delete","file":"iris.csv @ /tmp/Rtmpp1dzyw/test1ebe3ed83466"}