use std::sync::Arc; use sqlx::SqlitePool; pub trait Dao { fn pool(&self) -> &SqlitePool; fn new(pool: Arc) -> Self; fn add(&self, m: &mut M) -> impl std::future::Future> + Send; fn remove(&self, id: &str) -> impl std::future::Future> + Send; fn remove_all(&self) -> impl std::future::Future> + Send; fn update(&self, m: &mut M) -> impl std::future::Future> + Send; /// update with ol(Optimistic Locking) fn update_ol(&self, m: &mut M) -> impl std::future::Future> + Send; fn get(&self, id: &str) -> impl std::future::Future, sqlx::Error>> + Send; fn list(&self) -> impl std::future::Future, sqlx::Error>> + Send; } pub struct MBase { pub id: String, /// timestamp, ms pub update_ts: i64, pub version: i64, } impl MBase { pub const T_ID: &'static str = "id"; pub const T_UPDATE_TS: &'static str = "update_ts"; pub const T_VERSION: &'static str = "version"; }