Struct sqlx::query::QueryScalar
source · pub struct QueryScalar<'q, DB, O, A>where
DB: Database,{ /* private fields */ }
Expand description
Raw SQL query with bind parameters, mapped to a concrete type using FromRow
on (O,)
.
Returned from query_scalar
.
Implementations§
source§impl<'q, DB, O> QueryScalar<'q, DB, O, <DB as HasArguments<'q>>::Arguments>where
DB: Database,
impl<'q, DB, O> QueryScalar<'q, DB, O, <DB as HasArguments<'q>>::Arguments>where DB: Database,
sourcepub fn bind<T>(
self,
value: T
) -> QueryScalar<'q, DB, O, <DB as HasArguments<'q>>::Arguments>where
T: 'q + Send + Encode<'q, DB> + Type<DB>,
pub fn bind<T>( self, value: T ) -> QueryScalar<'q, DB, O, <DB as HasArguments<'q>>::Arguments>where T: 'q + Send + Encode<'q, DB> + Type<DB>,
Bind a value for use with this SQL query.
See Query::bind
.
source§impl<'q, DB, O, A> QueryScalar<'q, DB, O, A>where
DB: Database + HasStatementCache,
impl<'q, DB, O, A> QueryScalar<'q, DB, O, A>where DB: Database + HasStatementCache,
sourcepub fn persistent(self, value: bool) -> QueryScalar<'q, DB, O, A>
pub fn persistent(self, value: bool) -> QueryScalar<'q, DB, O, A>
If true
, the statement will get prepared once and cached to the
connection’s statement cache.
If queried once with the flag set to true
, all subsequent queries
matching the one with the flag will use the cached statement until the
cache is cleared.
Default: true
.
source§impl<'q, DB, O, A> QueryScalar<'q, DB, O, A>where
DB: Database,
O: Send + Unpin,
A: 'q + IntoArguments<'q, DB>,
(O,): Send + Unpin + for<'r> FromRow<'r, <DB as Database>::Row>,
impl<'q, DB, O, A> QueryScalar<'q, DB, O, A>where DB: Database, O: Send + Unpin, A: 'q + IntoArguments<'q, DB>, (O,): Send + Unpin + for<'r> FromRow<'r, <DB as Database>::Row>,
sourcepub fn fetch<'e, 'c, E>(
self,
executor: E
) -> Pin<Box<dyn Stream<Item = Result<O, Error>> + Send + 'e, Global>>where
'c: 'e,
'q: 'e,
E: 'e + Executor<'c, Database = DB>,
DB: 'e,
A: 'e,
O: 'e,
pub fn fetch<'e, 'c, E>( self, executor: E ) -> Pin<Box<dyn Stream<Item = Result<O, Error>> + Send + 'e, Global>>where 'c: 'e, 'q: 'e, E: 'e + Executor<'c, Database = DB>, DB: 'e, A: 'e, O: 'e,
Execute the query and return the generated results as a stream.
sourcepub fn fetch_many<'e, 'c, E>(
self,
executor: E
) -> Pin<Box<dyn Stream<Item = Result<Either<<DB as Database>::QueryResult, O>, Error>> + Send + 'e, Global>>where
'c: 'e,
'q: 'e,
E: 'e + Executor<'c, Database = DB>,
DB: 'e,
A: 'e,
O: 'e,
pub fn fetch_many<'e, 'c, E>( self, executor: E ) -> Pin<Box<dyn Stream<Item = Result<Either<<DB as Database>::QueryResult, O>, Error>> + Send + 'e, Global>>where 'c: 'e, 'q: 'e, E: 'e + Executor<'c, Database = DB>, DB: 'e, A: 'e, O: 'e,
Execute multiple queries and return the generated results as a stream from each query, in a stream.
sourcepub async fn fetch_all<'e, 'c, E>(
self,
executor: E
) -> impl Future<Output = Result<Vec<O, Global>, Error>>where
'c: 'e,
'q: 'e,
E: 'e + Executor<'c, Database = DB>,
DB: 'e,
(O,): 'e,
A: 'e,
pub async fn fetch_all<'e, 'c, E>( self, executor: E ) -> impl Future<Output = Result<Vec<O, Global>, Error>>where 'c: 'e, 'q: 'e, E: 'e + Executor<'c, Database = DB>, DB: 'e, (O,): 'e, A: 'e,
Execute the query and return all the generated results, collected into a Vec
.
Trait Implementations§
source§impl<'q, DB, O, A> Execute<'q, DB> for QueryScalar<'q, DB, O, A>where
DB: Database,
O: Send,
A: Send + 'q + IntoArguments<'q, DB>,
impl<'q, DB, O, A> Execute<'q, DB> for QueryScalar<'q, DB, O, A>where DB: Database, O: Send, A: Send + 'q + IntoArguments<'q, DB>,
source§fn statement(&self) -> Option<&<DB as HasStatement<'q>>::Statement>
fn statement(&self) -> Option<&<DB as HasStatement<'q>>::Statement>
Gets the previously cached statement, if available.
source§fn take_arguments(&mut self) -> Option<<DB as HasArguments<'q>>::Arguments>
fn take_arguments(&mut self) -> Option<<DB as HasArguments<'q>>::Arguments>
Returns the arguments to be bound against the query string. Read more
source§fn persistent(&self) -> bool
fn persistent(&self) -> bool
Returns
true
if the statement should be cached.