mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
Add WIP sqlite store
This commit is contained in:
@@ -19,6 +19,7 @@ sqlx = { version = "0.7.1", features = [
|
||||
"postgres",
|
||||
"sqlite",
|
||||
"runtime-tokio",
|
||||
"migrate",
|
||||
] }
|
||||
tokio = { version = "1.32.0", features = ["sync", "full"] }
|
||||
toml = "0.7.6"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
pub mod calendar;
|
||||
pub mod event;
|
||||
pub mod sqlite_store;
|
||||
pub mod timestamps;
|
||||
pub mod toml_store;
|
||||
|
||||
54
crates/store/src/sqlite_store.rs
Normal file
54
crates/store/src/sqlite_store.rs
Normal file
@@ -0,0 +1,54 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use async_trait::async_trait;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
use crate::calendar::{Calendar, CalendarStore};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct SqliteCalendarStore {
|
||||
db: Arc<SqlitePool>,
|
||||
}
|
||||
|
||||
impl SqliteCalendarStore {
|
||||
pub fn new(db: Arc<SqlitePool>) -> Self {
|
||||
Self { db }
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl CalendarStore for SqliteCalendarStore {
|
||||
async fn get_calendar(&self, id: &str) -> Result<Calendar> {
|
||||
let a = sqlx::query_as!(
|
||||
Calendar,
|
||||
"SELECT id, name, owner, description, color, timezone FROM calendars WHERE id = ?",
|
||||
id
|
||||
);
|
||||
Err(anyhow!("ok wow"))
|
||||
}
|
||||
|
||||
async fn get_calendars(&self, _owner: &str) -> Result<Vec<Calendar>> {
|
||||
Err(anyhow!("ok wow"))
|
||||
}
|
||||
|
||||
async fn insert_calendar(&mut self, _cid: String, _calendar: Calendar) -> Result<()> {
|
||||
Err(anyhow!("ok wow"))
|
||||
}
|
||||
|
||||
async fn get_events(&self, _cid: &str) -> Result<Vec<crate::event::Event>> {
|
||||
Err(anyhow!("ok wow"))
|
||||
}
|
||||
|
||||
async fn get_event(&self, _cid: &str, _uid: &str) -> Result<crate::event::Event> {
|
||||
Err(anyhow!("ok wow"))
|
||||
}
|
||||
|
||||
async fn upsert_event(&mut self, _cid: String, _uid: String, _ics: String) -> Result<()> {
|
||||
Err(anyhow!("ok wow"))
|
||||
}
|
||||
|
||||
async fn delete_event(&mut self, _cid: &str, _uid: &str) -> Result<()> {
|
||||
Err(anyhow!("ok wow"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user