Function with_postgres_connection

Source
pub async fn with_postgres_connection<F, R, E>(
    connection_string: impl Into<String>,
    operation: F,
) -> Result<R, PostgresError>
where F: FnOnce(&PostgresConnection) -> BoxFuture<'_, Result<R, E>>, E: Error + Send + Sync + 'static,
Expand description

Execute a function with a direct database connection using tokio-postgres This is the most efficient way to perform a one-off database operation The connection is automatically closed when the operation completes