Struct fire_postgres::connection::Connection
source · 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<u32, Error>
pub async fn count( &self, table: &str, column: &str, filter: impl Borrow<Filter<'_>> ) -> Result<u32, 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 copy 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