
List available content from the connector
Source:R/cnt_generics.R
, R/dbi_methods.R
, R/fs_methods.R
, and 1 more
list_content_cnt.Rd
Generic implementing of how to list all content available for different connectors:
ConnectorDBI: Uses
DBI::dbListTables()
to list the tables in a DBI connection.
ConnectorFS: Uses
list.files()
to list all files at the path of the connector.
ConnectorLogger: Logs the list operation and calls the underlying connector method.
Usage
list_content_cnt(connector_object, ...)
# S3 method for class 'ConnectorDBI'
list_content_cnt(connector_object, ...)
# S3 method for class 'ConnectorFS'
list_content_cnt(connector_object, ...)
# S3 method for class 'ConnectorLogger'
list_content_cnt(connector_object, ...)
Arguments
- connector_object
Connector The connector object to use.
- ...
Additional arguments passed to the method for the individual connector.
Value
A character vector of content names
Examples
# List tables in a DBI database
cnt <- connector_dbi(RSQLite::SQLite())
cnt |>
list_content_cnt()
#> character(0)
# List content in a file storage
folder <- withr::local_tempdir("test", .local_envir = .GlobalEnv)
cnt <- connector_fs(folder)
cnt |>
list_content_cnt()
#> character(0)
#' # Write a file to the file storage
cnt |>
write_cnt(iris, "iris.csv")
# Only list CSV files using the pattern argument of list.files
cnt |>
list_content_cnt(pattern = "\\.csv$")
#> [1] "iris.csv"
# Add logging to a connector and list contents
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:02","type":"write","file":"iris.csv @ /tmp/Rtmpp1dzyw/test1ebe766709cb"}
cnt$data |>
list_content_cnt()
#> {"time":"2025-08-20 06:16:02","type":"read","file":". @ /tmp/Rtmpp1dzyw/test1ebe766709cb"}
#> [1] "iris.csv"