pub struct Connection<'a> { /* private fields */ }
Implementations§
Source§impl Connection<'_>
impl Connection<'_>
pub async fn select<R>(
&self,
table: &str,
filter: impl Borrow<Filter<'_>>,
) -> Result<Vec<R>, Error>where
R: FromRowOwned + NamedColumns,
pub async fn select_one<R>(
&self,
table: &str,
filter: impl Borrow<Filter<'_>>,
) -> Result<R, Error>where
R: FromRowOwned + NamedColumns,
pub async fn select_opt<R>(
&self,
table: &str,
filter: impl Borrow<Filter<'_>>,
) -> Result<Option<R>, Error>where
R: FromRowOwned + NamedColumns,
Sourcepub async fn count(
&self,
table: &str,
column: &str,
filter: impl Borrow<Filter<'_>>,
) -> Result<u64, Error>
pub async fn count( &self, table: &str, column: &str, filter: impl Borrow<Filter<'_>>, ) -> Result<u64, Error>
count
A column is required because you should select a column which has some indexes on it, this makes the call a lot cheaper
pub async fn insert<U>(&self, table: &str, item: &U) -> Result<(), Error>where
U: ToRow,
pub async fn insert_many<U, I>( &self, table: &str, items: I, ) -> Result<(), Error>
pub async fn update<U>(
&self,
table: &str,
item: &U,
filter: impl Borrow<WhereFilter<'_>>,
) -> Result<(), Error>where
U: ToRow,
pub async fn delete( &self, table: &str, filter: impl Borrow<WhereFilter<'_>>, ) -> Result<(), Error>
Sourcepub async fn prepare_cached(&self, query: &str) -> Result<Statement, Error>
pub async fn prepare_cached(&self, query: &str) -> Result<Statement, Error>
Like tokio_postgres::Client::prepare_typed()
but uses a cached
statement if one exists.
Sourcepub async fn prepare_typed_cached(
&self,
query: &str,
types: &[Type],
) -> Result<Statement, Error>
pub async fn prepare_typed_cached( &self, query: &str, types: &[Type], ) -> Result<Statement, Error>
Like tokio_postgres::Client::prepare_typed()
but uses a cached
statement if one exists.
Sourcepub async fn prepare_typed(
&self,
query: &str,
parameter_types: &[Type],
) -> Result<Statement, Error>
pub async fn prepare_typed( &self, query: &str, parameter_types: &[Type], ) -> Result<Statement, Error>
Sourcepub async fn query<R, T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> Result<Vec<R>, Error>
pub async fn query<R, T>( &self, statement: &T, params: &[&(dyn ToSql + Sync)], ) -> Result<Vec<R>, Error>
Sourcepub async fn query_one<R, T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> Result<R, Error>
pub async fn query_one<R, T>( &self, statement: &T, params: &[&(dyn ToSql + Sync)], ) -> Result<R, Error>
Sourcepub async fn query_opt<R, T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> Result<Option<R>, Error>
pub async fn query_opt<R, T>( &self, statement: &T, params: &[&(dyn ToSql + Sync)], ) -> Result<Option<R>, Error>
Sourcepub async fn query_raw_opt<R, T, P, I>(
&self,
statement: &T,
params: I,
) -> Result<Option<R>, Error>where
R: FromRowOwned,
T: ?Sized + ToStatement,
P: BorrowToSql,
I: IntoIterator<Item = P>,
I::IntoIter: ExactSizeIterator,
pub async fn query_raw_opt<R, T, P, I>(
&self,
statement: &T,
params: I,
) -> Result<Option<R>, Error>where
R: FromRowOwned,
T: ?Sized + ToStatement,
P: BorrowToSql,
I: IntoIterator<Item = P>,
I::IntoIter: ExactSizeIterator,
Sourcepub async fn query_raw<T, P, I>(
&self,
statement: &T,
params: I,
) -> Result<RowStream, Error>where
T: ?Sized + ToStatement,
P: BorrowToSql,
I: IntoIterator<Item = P>,
I::IntoIter: ExactSizeIterator,
pub async fn query_raw<T, P, I>(
&self,
statement: &T,
params: I,
) -> Result<RowStream, Error>where
T: ?Sized + ToStatement,
P: BorrowToSql,
I: IntoIterator<Item = P>,
I::IntoIter: ExactSizeIterator,
Sourcepub async fn execute<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> Result<u64, Error>where
T: ?Sized + ToStatement,
pub async fn execute<T>(
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> Result<u64, Error>where
T: ?Sized + ToStatement,
Sourcepub async fn execute_raw<T, P, I>(
&self,
statement: &T,
params: I,
) -> Result<u64, Error>where
T: ?Sized + ToStatement,
P: BorrowToSql,
I: IntoIterator<Item = P>,
I::IntoIter: ExactSizeIterator,
pub async fn execute_raw<T, P, I>(
&self,
statement: &T,
params: I,
) -> Result<u64, Error>where
T: ?Sized + ToStatement,
P: BorrowToSql,
I: IntoIterator<Item = P>,
I::IntoIter: ExactSizeIterator,
Trait Implementations§
Source§impl<'a> Clone for Connection<'a>
impl<'a> Clone for Connection<'a>
Source§fn clone(&self) -> Connection<'a>
fn clone(&self) -> Connection<'a>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<'a> Debug for Connection<'a>
impl<'a> Debug for Connection<'a>
impl<'a> Copy for Connection<'a>
Auto Trait Implementations§
impl<'a> Freeze for Connection<'a>
impl<'a> !RefUnwindSafe for Connection<'a>
impl<'a> Send for Connection<'a>
impl<'a> Sync for Connection<'a>
impl<'a> Unpin for Connection<'a>
impl<'a> !UnwindSafe for Connection<'a>
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