R/odbc_get_id.R

Defines functions odbc_get_id

Documented in odbc_get_id

#' Get the id of the matching records
#' @export
#' @param table The name of the table
#' @param ... arguments passed to `filter()`.
#' @param schema The schema of the table. Defaults to public
#' @param channel the open dplyr connection to the database.
#' @param id_variable name of the id variable
#' @importFrom dplyr %>% collect filter select
#' @importFrom rlang .data
odbc_get_id <- function(
    table, ..., schema = "public", channel, id_variable = "id"
) {
  # nocov start
  tbl(channel, table) %>%
    filter(...) %>%
    select(.data[[id_variable]]) %>%
    collect() %>%
    unlist() %>%
    unname() # nocov end
}
INBO-Natura2000/n2khelper documentation built on April 5, 2022, 5:40 p.m.