1pub trait SqlForgeQuery<Output> {
2 type Db: sqlx::Database;
3
4 fn fetch_all<'e, E>(
5 self,
6 executor: E,
7 ) -> impl std::future::Future<Output = Result<Vec<Output>, sqlx::Error>> + Send + 'e
8 where
9 Self: Sized + 'e,
10 E: sqlx::Executor<'e, Database = Self::Db> + Send + 'e,
11 Self::Db: 'e;
12
13 fn fetch_one<'e, E>(
14 self,
15 executor: E,
16 ) -> impl std::future::Future<Output = Result<Output, sqlx::Error>> + Send + 'e
17 where
18 Self: Sized + 'e,
19 E: sqlx::Executor<'e, Database = Self::Db> + Send + 'e,
20 Self::Db: 'e;
21
22 fn fetch_optional<'e, E>(
23 self,
24 executor: E,
25 ) -> impl std::future::Future<Output = Result<Option<Output>, sqlx::Error>> + Send + 'e
26 where
27 Self: Sized + 'e,
28 E: sqlx::Executor<'e, Database = Self::Db> + Send + 'e,
29 Self::Db: 'e;
30
31 fn execute<'e, E>(
32 self,
33 executor: E,
34 ) -> impl std::future::Future<
35 Output = Result<<Self::Db as sqlx::Database>::QueryResult, sqlx::Error>,
36 > + Send
37 + 'e
38 where
39 Self: Sized + 'e,
40 E: sqlx::Executor<'e, Database = Self::Db> + Send + 'e,
41 Self::Db: 'e;
42}
43
44pub trait SqlForgeQueryExecute {
45 type Db: sqlx::Database;
46
47 fn execute<'e, E>(
48 self,
49 executor: E,
50 ) -> impl std::future::Future<
51 Output = Result<<Self::Db as sqlx::Database>::QueryResult, sqlx::Error>,
52 > + Send
53 + 'e
54 where
55 Self: Sized + 'e,
56 E: sqlx::Executor<'e, Database = Self::Db> + Send + 'e,
57 Self::Db: 'e;
58}
59
60pub trait SqlForgeQueryGroup {
61 type Db: sqlx::Database;
62}
63
64pub trait SqlForgeQueryGroupGet<Key, Output>: SqlForgeQueryGroup {
65 type Query: SqlForgeQuery<Output, Db = Self::Db>;
66
67 fn get(self, _: Key) -> Self::Query;
68}