Remove content from the connector
Source:R/cnt_generics.R
, R/dbi_methods.R
, R/fs_methods.R
remove_cnt.Rd
Generic implementing of how to remove content from different connectors:
connector_dbi: Uses
DBI::dbRemoveTable()
to remove the table from a DBI connection.
connector_fs: Uses
unlink()
to delete the file.
Usage
remove_cnt(connector_object, name, ...)
# S3 method for class 'connector_dbi'
remove_cnt(connector_object, name, ...)
# S3 method for class 'connector_fs'
remove_cnt(connector_object, name, ...)
Value
invisible connector_object.
Examples
# Remove table in a DBI database
cnt <- connector_dbi$new(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
cnt <- connector_fs$new(tempdir())
cnt |>
write_cnt("this is an example", "example.txt")
cnt |>
list_content_cnt(pattern = "example.txt")
#> [1] "example.txt"
cnt |>
read_cnt("example.txt")
#> [1] "this is an example"
cnt |>
remove_cnt("example.txt")
cnt |>
list_content_cnt(pattern = "example.txt")
#> character(0)