Trait diesel::prelude::LoadDsl
[−]
[src]
pub trait LoadDsl<Conn: Connection>: AsQuery + Sized where Self::Query: QueryFragment<Conn::Backend>, Conn::Backend: HasSqlType<Self::SqlType> { fn load<'a, U>(self, conn: &Conn) -> QueryResult<Vec<U>> where U: Queryable<Self::SqlType, Conn::Backend> + 'a { ... } fn first<U>(self, conn: &Conn) -> QueryResult<U> where Self: LimitDsl, U: Queryable<Limit<Self>::SqlType, Conn::Backend>, Limit<Self>: QueryFragment<Conn::Backend>, Conn::Backend: HasSqlType<Limit<Self>::SqlType> { ... } fn get_result<U>(self, conn: &Conn) -> QueryResult<U> where U: Queryable<Self::SqlType, Conn::Backend> { ... } fn get_results<'a, U>(self, conn: &Conn) -> QueryResult<Vec<U>> where U: Queryable<Self::SqlType, Conn::Backend> + 'a { ... } }
Methods to execute a query given a connection. These are automatically implemented for the various query types.
Provided Methods
fn load<'a, U>(self, conn: &Conn) -> QueryResult<Vec<U>> where U: Queryable<Self::SqlType, Conn::Backend> + 'a
Executes the given query, returning an Iterator
over the returned
rows.
fn first<U>(self, conn: &Conn) -> QueryResult<U> where Self: LimitDsl, U: Queryable<Limit<Self>::SqlType, Conn::Backend>, Limit<Self>: QueryFragment<Conn::Backend>, Conn::Backend: HasSqlType<Limit<Self>::SqlType>
Attempts to load a single record. Returns Ok(record)
if found, and
Err(NotFound)
if no results are returned. If the query truly is
optional, you can call .optional()
on the result of this to get a
Result<Option<U>>
.
fn get_result<U>(self, conn: &Conn) -> QueryResult<U> where U: Queryable<Self::SqlType, Conn::Backend>
Runs the command, and returns the affected row. Err(NotFound)
will be
returned if the query affected 0 rows. You can call .optional()
on the
result of this if the command was optional to get back a
Result<Option<U>>
fn get_results<'a, U>(self, conn: &Conn) -> QueryResult<Vec<U>> where U: Queryable<Self::SqlType, Conn::Backend> + 'a
Runs the command, returning an Iterator
over the affected rows.
Implementors
impl<Conn: Connection, T: AsQuery> LoadDsl<Conn> for T where T::Query: QueryFragment<Conn::Backend>, Conn::Backend: HasSqlType<T::SqlType>