Learn R Programming

connector (version 1.0.0)

list_content_cnt: List available content from the connector

Description

Generic implementing of how to list all content available for different connectors:

  • 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 ConnectorDBI list_content_cnt(connector_object, ...)

# S3 method for ConnectorFS list_content_cnt(connector_object, ...)

# S3 method for ConnectorLogger list_content_cnt(connector_object, ...)

Value

A character vector of content names

Arguments

connector_object

Connector The connector object to use.

...

Additional arguments passed to the method for the individual connector.

Examples

Run this code
# List tables in a DBI database
cnt <- connector_dbi(RSQLite::SQLite())

cnt |>
  list_content_cnt()

# List content in a file storage
folder <- withr::local_tempdir("test", .local_envir = .GlobalEnv)

cnt <- connector_fs(folder)

cnt |>
  list_content_cnt()

#' # 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$")

# 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")

cnt$data |>
  list_content_cnt()

Run the code above in your browser using DataLab