pub struct DatabaseConnection { /* private fields */ }Expand description
Wrapper around a single pooled database connection.
Instances of this type are passed to route handlers and expose helper methods for common CRUD operations.
Implementations§
Source§impl DatabaseConnection
impl DatabaseConnection
Sourcepub async fn query<T: AsRef<str>>(
&self,
query: T,
args: &[&(dyn ToSql + Sync)],
) -> Result<Vec<Row>, Error>
pub async fn query<T: AsRef<str>>( &self, query: T, args: &[&(dyn ToSql + Sync)], ) -> Result<Vec<Row>, Error>
Execute a raw SQL query and return the resulting rows.
Sourcepub async fn insert<T: FromPostgres + PostgresTable + PostgresReadFields>(
&self,
write: PostgresWrite,
) -> Result<T, PostgresWriteError>
pub async fn insert<T: FromPostgres + PostgresTable + PostgresReadFields>( &self, write: PostgresWrite, ) -> Result<T, PostgresWriteError>
Insert a single record and return the inserted row.
Sourcepub async fn insert_vec<T: FromPostgres + PostgresTable + PostgresReadable>(
&self,
write: PostgresWrite,
) -> Result<Vec<T>, PostgresWriteError>
pub async fn insert_vec<T: FromPostgres + PostgresTable + PostgresReadable>( &self, write: PostgresWrite, ) -> Result<Vec<T>, PostgresWriteError>
Insert many records and return the inserted rows.
Auto Trait Implementations§
impl Freeze for DatabaseConnection
impl !RefUnwindSafe for DatabaseConnection
impl Send for DatabaseConnection
impl Sync for DatabaseConnection
impl Unpin for DatabaseConnection
impl !UnwindSafe for DatabaseConnection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more