1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use connection::{Connection, Cursor};
use query_builder::{Query, QueryFragment, AsQuery};
use query_source::Queriable;
use result::QueryResult;
use super::LimitDsl;
pub trait LoadDsl: AsQuery + Sized {
fn load<U>(self, conn: &Connection) -> QueryResult<Cursor<Self::SqlType, U>> where
U: Queriable<Self::SqlType>
{
conn.query_all(self)
}
fn first<U>(self, conn: &Connection) -> QueryResult<U> where
U: Queriable<<<Self as LimitDsl>::Output as Query>::SqlType>,
Self: LimitDsl,
{
conn.query_one(self.limit(1))
}
fn get_result<U>(self, conn: &Connection) -> QueryResult<U> where
U: Queriable<Self::SqlType>,
{
conn.query_one(self)
}
fn get_results<U>(self, conn: &Connection) -> QueryResult<Cursor<Self::SqlType, U>> where
U: Queriable<Self::SqlType>
{
self.load(conn)
}
}
impl<T: AsQuery> LoadDsl for T {
}
pub trait ExecuteDsl: QueryFragment + Sized {
fn execute(&self, conn: &Connection) -> QueryResult<usize> {
conn.execute_returning_count(self)
}
}
impl<T: QueryFragment> ExecuteDsl for T {
}