flyer_orm/databases/postgres/
mod.rs1mod builder;
2pub mod query;
3
4use anyhow::Result;
5use sqlx::{FromRow, PgPool, Pool, Postgres as DBPostgres};
6
7use crate::{Executor, databases::postgres::query::PostgresQueryResult, query::{Pagination, Statement}};
8
9pub struct Postgres {
10 db: Pool<DBPostgres>,
11}
12
13impl Postgres {
14 pub async fn connect(url: &str) -> Result<Self> {
15 return Ok(Self {
16 db: PgPool::connect(url).await.unwrap()
17 });
18 }
19}
20
21impl Executor for Postgres {
22 type T = DBPostgres;
23
24 async fn new(url: &str) -> Self where Self: Sized {
25 todo!()
26 }
27
28 fn db<'q>(&'q self) -> &'q Pool<Self::T> {
29 todo!()
30 }
31
32 fn to_sql<'q>(&self, statement: &'q Statement<'q, Self::T>) -> Result<String> {
33 todo!()
34 }
35
36 #[allow(refining_impl_trait)]
37 async fn execute<'q>(&self, sql: &'q str) -> Result<PostgresQueryResult> {
38 todo!();
39 }
40
41 async fn insert<'q>(&self, statement: &'q Statement<'q, Self::T>) -> Result<()> {
42 todo!()
43 }
44
45 async fn insert_as<'q, O>(&self, statement: &'q Statement<'q, Self::T>) -> Result<O>
46 where
47 O: for<'r> sqlx::FromRow<'r, <Self::T as sqlx::Database>::Row> + Send + Unpin + Sized
48 {
49 todo!()
50 }
51
52 async fn update<'q>(&self, statement: &'q Statement<'q, Self::T>) -> Result<()> {
53 todo!()
54 }
55
56 async fn count<'q>(&self, statement: &'q Statement<'q, Self::T>) -> Result<u64> {
57 return Ok(0);
58 }
59
60 async fn delete<'q>(&self, statement: &'q Statement<'q, Self::T>) -> Result<()> {
61 todo!()
62 }
63
64 async fn query_all<'q, O, T: 'q + sqlx::Encode<'q, Self::T> + sqlx::Type<Self::T>>(&self, sql: &str, args: Vec<T>) -> Result<Vec<O>>
65 where
66 O: for<'r> FromRow<'r, <Self::T as sqlx::Database>::Row> + Send + Unpin + Sized {
67 todo!()
68 }
69
70 async fn query_one<'q, O, T: 'q + sqlx::Encode<'q, Self::T> + sqlx::Type<Self::T>>(&self, sql: &str, args: Vec<T>) -> Result<O>
71 where
72 O: for<'r> FromRow<'r, <Self::T as sqlx::Database>::Row> + Send + Unpin + Sized {
73 todo!()
74 }
75
76 async fn all<'q, O>(&self, statement: &'q Statement<'q, Self::T>) -> Result<Vec<O>>
77 where
78 O: for<'r> FromRow<'r, <Self::T as sqlx::Database>::Row> + Send + Unpin + Sized {
79 todo!()
80 }
81
82 async fn first<'q, O>(&self, statement: &'q Statement<'q, Self::T>) -> Result<O>
83 where
84 O: for<'r> FromRow<'r, <Self::T as sqlx::Database>::Row> + Send + Unpin + Sized {
85 todo!()
86 }
87
88 async fn paginate<'q, O>(&self, statement: &'q Statement<'q, Self::T>) -> Result<Pagination<O>>
89 where
90 O: for<'r> FromRow<'r, <Self::T as sqlx::Database>::Row> + Send + Unpin + Sized {
91 todo!()
92 }
93}