Struct sqlx::query::Map[][src]

#[must_use = "query must be executed to affect database"]pub struct Map<'q, DB, F, A> where
    DB: Database
{ /* fields omitted */ }

SQL query that will map its results to owned Rust types.

Returned by Query::try_map, query!(), etc. Has most of the same methods as Query but the return types are changed to reflect the mapping. However, there is no equivalent of Query::execute as it doesn't make sense to map the result type and then ignore it.

Query::bind is also omitted; stylistically we recommend placing your .bind() calls before .try_map(). This is also to prevent adding superfluous binds to the result of query!() et al.

Implementations

impl<'q, DB, F, O, A> Map<'q, DB, F, A> where
    A: 'q + Send + IntoArguments<'q, DB>,
    O: Send + Unpin,
    F: FnMut(<DB as Database>::Row) -> Result<O, Error> + Send,
    DB: Database
[src]

pub fn map<G, P>(
    self,
    g: G
) -> Map<'q, DB, impl Send + FnMut(<DB as Database>::Row), A> where
    P: Unpin,
    G: FnMut(O) -> P + Send
[src]

Map each row in the result to another type.

See try_map for a fallible version of this method.

The query_as method will construct a mapped query using a FromRow implementation.

pub fn try_map<G, P>(
    self,
    g: G
) -> Map<'q, DB, impl Send + FnMut(<DB as Database>::Row), A> where
    P: Unpin,
    G: FnMut(O) -> Result<P, Error> + Send
[src]

Map each row in the result to another type.

The query_as method will construct a mapped query using a FromRow implementation.

pub fn fetch<'e, 'c, E>(
    self,
    executor: E
) -> Pin<Box<dyn Stream<Item = Result<O, Error>> + 'e + Send, Global>> where
    'c: 'e,
    'q: 'e,
    O: 'e,
    F: 'e,
    DB: 'e,
    E: 'e + Executor<'c, Database = DB>, 
[src]

Execute the query and return the generated results as a stream.

pub fn fetch_many<'e, 'c, E>(
    self,
    executor: E
) -> Pin<Box<dyn Stream<Item = Result<Either<<DB as Database>::QueryResult, O>, Error>> + 'e + Send, Global>> where
    'c: 'e,
    'q: 'e,
    O: 'e,
    F: 'e,
    DB: 'e,
    E: 'e + Executor<'c, Database = DB>, 
[src]

Execute multiple queries and return the generated results as a stream from each query, in a stream.

pub async fn fetch_all<'e, 'c, E>(
    self,
    executor: E
) -> Result<Vec<O, Global>, Error> where
    'c: 'e,
    'q: 'e,
    O: 'e,
    F: 'e,
    DB: 'e,
    E: 'e + Executor<'c, Database = DB>, 
[src]

Execute the query and return all the generated results, collected into a Vec.

pub async fn fetch_one<'e, 'c, E>(self, executor: E) -> Result<O, Error> where
    'c: 'e,
    'q: 'e,
    O: 'e,
    F: 'e,
    DB: 'e,
    E: 'e + Executor<'c, Database = DB>, 
[src]

Execute the query and returns exactly one row.

pub async fn fetch_optional<'e, 'c, E>(
    self,
    executor: E
) -> Result<Option<O>, Error> where
    'c: 'e,
    'q: 'e,
    O: 'e,
    F: 'e,
    DB: 'e,
    E: 'e + Executor<'c, Database = DB>, 
[src]

Execute the query and returns at most one row.

Trait Implementations

impl<'q, DB, F, A> Execute<'q, DB> for Map<'q, DB, F, A> where
    A: Send + IntoArguments<'q, DB>,
    F: Send,
    DB: Database
[src]

Auto Trait Implementations

impl<'q, DB, F, A> RefUnwindSafe for Map<'q, DB, F, A> where
    A: RefUnwindSafe,
    DB: RefUnwindSafe,
    F: RefUnwindSafe,
    <DB as HasStatement<'q>>::Statement: RefUnwindSafe
[src]

impl<'q, DB, F, A> Send for Map<'q, DB, F, A> where
    A: Send,
    F: Send
[src]

impl<'q, DB, F, A> Sync for Map<'q, DB, F, A> where
    A: Sync,
    DB: Sync,
    F: Sync
[src]

impl<'q, DB, F, A> Unpin for Map<'q, DB, F, A> where
    A: Unpin,
    DB: Unpin,
    F: Unpin
[src]

impl<'q, DB, F, A> UnwindSafe for Map<'q, DB, F, A> where
    A: UnwindSafe,
    DB: UnwindSafe,
    F: UnwindSafe,
    <DB as HasStatement<'q>>::Statement: RefUnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> Conv for T

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> TryConv for T

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,