Trait diesel::prelude::LoadDsl
[−]
[src]
pub trait LoadDsl<Conn: Connection>: Sized where Conn::Backend: HasSqlType<Self::SqlType> { type SqlType; fn load<U>(self, conn: &Conn) -> QueryResult<Vec<U>> where U: Queryable<Self::SqlType, Conn::Backend>; fn get_result<U>(self, conn: &Conn) -> QueryResult<U> where U: Queryable<Self::SqlType, Conn::Backend>; fn first<U>(self, conn: &Conn) -> QueryResult<U> where Self: LimitDsl,
Limit<Self>: LoadDsl<Conn, SqlType=Self::SqlType>,
U: Queryable<Self::SqlType, Conn::Backend> { ... } fn get_results<U>(self, conn: &Conn) -> QueryResult<Vec<U>> where U: Queryable<Self::SqlType, Conn::Backend> { ... } }
Methods to execute a query given a connection. These are automatically implemented for the various query types.
Associated Types
type SqlType
Required Methods
fn load<U>(self, conn: &Conn) -> QueryResult<Vec<U>> where U: Queryable<Self::SqlType, Conn::Backend>
Executes the given query, returning an Iterator
over the returned
rows.
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>>
Provided Methods
fn first<U>(self, conn: &Conn) -> QueryResult<U> where Self: LimitDsl,
Limit<Self>: LoadDsl<Conn, SqlType=Self::SqlType>,
U: Queryable<Self::SqlType, Conn::Backend>
Limit<Self>: LoadDsl<Conn, SqlType=Self::SqlType>,
U: Queryable<Self::SqlType, Conn::Backend>
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_results<U>(self, conn: &Conn) -> QueryResult<Vec<U>> where U: Queryable<Self::SqlType, Conn::Backend>
Runs the command, returning an Iterator
over the affected rows.
Implementors
impl<'a, T, U, Op, Ret, Conn, ST> LoadDsl<Conn> for BatchInsertStatement<T, &'a [U], Op, Ret> where Conn: Connection,
Conn::Backend: HasSqlType<ST>,
InsertStatement<T, &'a [U], Op, Ret>: LoadDsl<Conn, SqlType=ST>impl<Conn: Connection, T: AsQuery> LoadDsl<Conn> for T where T::Query: QueryFragment<Conn::Backend> + QueryId,
Conn::Backend: HasSqlType<T::SqlType>