
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
cnt <- connector_fs(tempdir())
cnt |>
list_content_cnt()
#> [1] "bslib-2ce9eb5d8d7866b4f2d82a9ef19eb08f"
#> [2] "downlit"
#> [3] "file1e6433e230ab"
#> [4] "file1e643c3fa3fe"
#> [5] "file1e6440cd280c"
#> [6] "file1e6444e5ef61"
#> [7] "file1e644c54a37.yml"
#> [8] "file1e645d3adb45"
#> [9] "file1e64707ea9ba"
#> [10] "file1e647652183e"
#> [11] "file1e6478d4e656.yml"
#> [12] "file1e64da7f175"
#> [13] "file1e64ff8ab23"
#> [14] "repos_https%3A%2F%2Fpackagemanager.posit.co%2Fcran%2F__linux__%2Fnoble%2Flatest%2Fsrc%2Fcontrib.rds"
# Only list CSV files using the pattern argument of list.files
cnt |>
list_content_cnt(pattern = "\\.csv$")
#> character(0)
# Add logging to a connector and list contents
folder <- withr::local_tempdir()
cnt <- connectors(data = connector_fs(folder)) |> add_logs()
cnt$data |>
write_cnt(iris, "iris.csv")
#> Error: Cannot open file for writing:
#> * '/tmp/RtmpAvFMmW/file1e644154b58e/iris.csv'
cnt$data |>
list_content_cnt()
#> {"time":"2025-07-03 08:34:29","type":"read","file":". @ /tmp/RtmpAvFMmW/file1e644154b58e"}
#> character(0)