Re-jigged the class implementation to get better support from roxygen2 and CRAN check(). Majority of public functions are documented (remaining are the CRUD functions)

This commit is contained in:
2026-01-28 12:47:12 +00:00
parent b03c2691cd
commit 4a38372fc9
54 changed files with 900 additions and 279 deletions

View File

@@ -0,0 +1,30 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DBClient-dbCollect.R
\name{DBClient$collectGeometries}
\alias{DBClient$collectGeometries}
\title{DBClient$collectGeometries}
\arguments{
\item{qry}{\if{html}{\out{<complex>}} The query to collect}
\item{geometry_cols}{\if{html}{\out{<character>}} Any geometry columns to translate to sf}
\item{geometry_crs}{\if{html}{\out{<complex>}} The CRS to assign to the columns. Either
specified by the CRS number or an sf::st_crs() object.}
\item{check_ring_dir}{\if{html}{\out{<logical>}} Check the direction of rings during the
translation. See \code{sf::st_as_sfc} for further details.}
}
\value{
\if{html}{\out{<complex>}} The collected query with translated geometry columns
}
\description{
Requires sf package.
Runs dplyr::collect on a query, If there are gemoetry columns (specified by
gemoetry_cols or named geom or named proj) then they are translated into sf
geometry columns using sf::st_as_sfc with a CRS.
The default CRS for a column named \code{geom} is 4326.
The default CRS for a column named \code{proj} is 3035.
The default CRS for other geometry columns is specified by \code{geometry_crs}
}

View File

@@ -0,0 +1,18 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DBClient-dbCollect.R
\name{DBClient$collectOrReturn}
\alias{DBClient$collectOrReturn}
\title{DBClient$collectOrReturn}
\arguments{
\item{qry}{\if{html}{\out{<character>}} A dplyr query}
\item{collect}{\if{html}{\out{<logical>}} Collect the query. Defaults to checking parent frame
for the parameter value}
}
\value{
\if{html}{\out{<complex>}} The query, optionally collect'd
}
\description{
Utility method which returns the query and optionally runs dplyr::collect on
it first.
}

View File

@@ -0,0 +1,14 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DBClient-dbAction.R
\name{DBClient$dbAction}
\alias{DBClient$dbAction}
\title{DBClient$dbAction}
\arguments{
\item{statement}{\if{html}{\out{<character>}} Statement to run}
}
\value{
\if{html}{\out{<logical>}} TRUE if the execution was successful, FALSE if not
}
\description{
Executes a query/statement on a database which has no result
}

View File

@@ -0,0 +1,14 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DBClient-dbQuery.R
\name{DBClient$dbQuery}
\alias{DBClient$dbQuery}
\title{DBClient$dbQuery}
\arguments{
\item{statement}{\if{html}{\out{<character>}} Query to run on the database}
}
\value{
\if{html}{\out{<complex>}} A lazy data table with the results from the query
}
\description{
Runs a query (statement) on a database and returns the results
}

View File

@@ -0,0 +1,16 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DBClient-dbSchema.R
\name{DBClient$dplyrWithSchema}
\alias{DBClient$dplyrWithSchema}
\title{DBClient$dplyrWithSchema}
\arguments{
\item{table_name}{\if{html}{\out{<character>}} Table name to prefix schema to}
}
\value{
\if{html}{\out{<character>}} Table name with prefixed schema
}
\description{
Prefixes schema to the table name, if set in the configuration. Specifically
uses the dbplyr::in_schema method rather than the direct
DBI::dbQuoteIdentifier method.
}

View File

@@ -0,0 +1,8 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DBClient-Initialize.R
\name{DBClient$getConnection}
\alias{DBClient$getConnection}
\title{DBClient$getConnection}
\description{
Returns the DBConnection instance for this client
}

View File

@@ -0,0 +1,11 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DBClient-Initialize.R
\name{DBClient$initialize}
\alias{DBClient$initialize}
\title{DBClient$initialize}
\arguments{
\item{conn}{\if{html}{\out{<DBConnection>}} An instance of DBConnection}
}
\description{
Initalises the DBClient instance with a DBConnection
}

View File

@@ -0,0 +1,14 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DBClient-dbTable.R
\name{DBClient$table}
\alias{DBClient$table}
\title{DBClient$table}
\arguments{
\item{table_name}{\if{html}{\out{<character>}} The database table name}
}
\value{
\if{html}{\out{<complex>}} A dplyr::tbl instance
}
\description{
Creates a \code{dplyr::tbl} instantiation with the current database connection.
}

View File

@@ -0,0 +1,14 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DBClient-dbSchema.R
\name{DBClient$withSchema}
\alias{DBClient$withSchema}
\title{DBClient$withSchema}
\arguments{
\item{table_name}{\if{html}{\out{<character>}} Table name to prefix schema to}
}
\value{
\if{html}{\out{<character>}} Table name with prefixed schema
}
\description{
Prefixes schema to the table name, if set in the configuration.
}

View File

@@ -0,0 +1,14 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DBClient-dbTransaction.R
\name{DBClient$withTransaction}
\alias{DBClient$withTransaction}
\title{DBClient$withTransaction}
\arguments{
\item{expr}{\if{html}{\out{<expression>}} Expression to run in a transaction}
}
\value{
\if{html}{\out{<logical>}} TRUE if transaction was successful
}
\description{
Runs a given expression within a database transaction.
}

View File

@@ -0,0 +1,15 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DBConnection-Transaction.R
\name{DBConnection$beginTransaction}
\alias{DBConnection$beginTransaction}
\title{DBConnection$beginTransaction}
\arguments{
\item{session}{\if{html}{\out{<complex>}} The R Shiny session to register the callback with}
}
\value{
\if{html}{\out{<function>}} A function to cancel the onSessionEnded callback
}
\description{
Registers a callback with an R Shiny session so that the connection is
disconnected once the session ends.
}

View File

@@ -0,0 +1,18 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DBConnection-Transaction.R
\name{DBConnection$commitTransaction}
\alias{DBConnection$commitTransaction}
\title{DBConnection$commitTransaction}
\arguments{
\item{quietly}{\if{html}{\out{<logical>}} If there is no transaction, will cause a \code{stop()}
if TRUE}
}
\value{
\if{html}{\out{<function>}} A function to cancel the onSessionEnded callback
}
\description{
Commits the current database transaction. If nested, will not actually commit
until the last level is committed.
If \code{rollbackTransaction()}
}

View File

@@ -0,0 +1,18 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DBConnection-Configure.R
\name{DBConnection$configure}
\alias{DBConnection$configure}
\title{DBConnection$configure}
\arguments{
\item{...}{Named parameters for configuring the connection or a name list of
parameters}
}
\value{
\if{html}{\out{<list>}} The configuration that has loaded
}
\description{
Configures the DBClient instance.
There are 2 options for configuration, either: pass in a named list; or use
named parameters.
}

View File

@@ -0,0 +1,12 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DBConnection-Connect.R
\name{DBConnection$connect}
\alias{DBConnection$connect}
\title{DBConnection$connect}
\value{
\if{html}{\out{<logical>}} TRUE if connection was success, FALSE if it failed
}
\description{
Attempts to connect to the database. If not already configured, will first
attempt to load the configuration.
}

View File

@@ -0,0 +1,8 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DBConnection-Connect.R
\name{DBConnection$disconnect}
\alias{DBConnection$disconnect}
\title{DBConnection$disconnect}
\description{
Disconnects the current database connection, if connected.
}

View File

@@ -0,0 +1,15 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DBConnection-Connect.R
\name{DBConnection$disconnectOnSessionEnd}
\alias{DBConnection$disconnectOnSessionEnd}
\title{DBConnection$disconnectOnSessionEnd}
\arguments{
\item{session}{\if{html}{\out{<complex>}} The R Shiny session to register the callback with}
}
\value{
\if{html}{\out{<function>}} A function to cancel the onSessionEnded callback
}
\description{
Registers a callback with an R Shiny session so that the connection is
disconnected once the session ends.
}

View File

@@ -0,0 +1,11 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DBConnection-Configure.R
\name{DBConnection$getConfiguration}
\alias{DBConnection$getConfiguration}
\title{DBConnection$getConfiguration}
\value{
\if{html}{\out{<list>}} Current configuration. If not configured, NULL is returned
}
\description{
Get the current configuration of the DBClient instance.
}

View File

@@ -0,0 +1,14 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DBConnection-Connect.R
\name{DBConnection$getConnection}
\alias{DBConnection$getConnection}
\title{DBConnection$getConnection}
\arguments{
\item{do_connect}{\if{html}{\out{<logical>}} Forcibly connect if not already connected}
}
\value{
\if{html}{\out{<DBConnection>}} DBConnection instance
}
\description{
Returns the DBConnection instance for this client.
}

View File

@@ -0,0 +1,8 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DBConnection-Initialize.R
\name{DBConnection$getToken}
\alias{DBConnection$getToken}
\title{DBConnection$getToken}
\description{
Returns the identity token for this DBConnection instance.
}

View File

@@ -0,0 +1,8 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DBConnection-Initialize.R
\name{DBConnection$initialize}
\alias{DBConnection$initialize}
\title{DBConnection$initialize}
\description{
Initalises the DBConnection instance with an identity token.
}

View File

@@ -0,0 +1,11 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DBConnection-Connect.R
\name{DBConnection$isConnected}
\alias{DBConnection$isConnected}
\title{DBConnection$isConnected}
\value{
\if{html}{\out{<logical>}} TRUE if connected to the database, FALSE otherwise
}
\description{
Indicates if the instance has an active database connection.
}

View File

@@ -0,0 +1,14 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DBConnection-Configure.R
\name{DBConnection$loadConfiguration}
\alias{DBConnection$loadConfiguration}
\title{DBConnection$loadConfiguration}
\arguments{
\item{warn}{Emit a warning with which file it attempting to be loaded}
}
\value{
\if{html}{\out{<logical>}} TRUE if configuration was successful, FALSE otherwise
}
\description{
Attempts to load the configuration either from global.R or .env.R.
}

View File

@@ -0,0 +1,15 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DBConnection-Transaction.R
\name{DBConnection$rollbackTransaction}
\alias{DBConnection$rollbackTransaction}
\title{DBConnection$rollbackTransaction}
\arguments{
\item{session}{\if{html}{\out{<complex>}} The R Shiny session to register the callback with}
}
\value{
\if{html}{\out{<function>}} A function to cancel the onSessionEnded callback
}
\description{
Registers a callback with an R Shiny session so that the connection is
disconnected once the session ends.
}

View File

@@ -4,5 +4,5 @@
\alias{DBConnection}
\title{DBConnection}
\description{
Database Connection class
Database Connection class.
}

View File

@@ -0,0 +1,44 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DBConnection-Configure.R
\name{.configureDefault}
\alias{.configureDefault}
\title{Configures the DBClient instance.}
\usage{
.configureDefault(
host,
port,
user,
password,
dbname,
engine = NULL,
name = NULL,
schema = NULL,
autoconnect = NULL
)
}
\arguments{
\item{host}{The database host}
\item{port}{The database port}
\item{user}{The database user to connect with}
\item{password}{The database password to connect with}
\item{dbname}{The database to use}
\item{engine}{The database engine (mysql, postgres) as supported by DBI}
\item{name}{The database to use (alternative to dbname)}
\item{schema}{The database schema to use (postgres)}
\item{autoconnect}{Autoconnect to the database if not already connected}
}
\value{
The configuration accepted
}
\description{
There are 2 options for configuration, either: pass in a named list; or use
named parameters.
}