| 1 |
use super::{DateTime, NewSavedView, Result, SavedView, SavedViewId, UserId, Utc, async_trait}; |
| 2 |
|
| 3 |
|
| 4 |
#[async_trait] |
| 5 |
pub trait SavedViewRepository: Send + Sync { |
| 6 |
|
| 7 |
async fn list_all(&self, user_id: UserId) -> Result<Vec<SavedView>>; |
| 8 |
|
| 9 |
|
| 10 |
async fn list_pinned(&self, user_id: UserId) -> Result<Vec<SavedView>>; |
| 11 |
|
| 12 |
|
| 13 |
async fn get_by_id(&self, id: SavedViewId, user_id: UserId) -> Result<Option<SavedView>>; |
| 14 |
|
| 15 |
|
| 16 |
async fn create(&self, user_id: UserId, view: NewSavedView) -> Result<SavedView>; |
| 17 |
|
| 18 |
|
| 19 |
async fn update( |
| 20 |
&self, |
| 21 |
id: SavedViewId, |
| 22 |
user_id: UserId, |
| 23 |
view: NewSavedView, |
| 24 |
) -> Result<Option<SavedView>>; |
| 25 |
|
| 26 |
|
| 27 |
async fn delete(&self, id: SavedViewId, user_id: UserId) -> Result<bool>; |
| 28 |
|
| 29 |
|
| 30 |
async fn toggle_pinned(&self, id: SavedViewId, user_id: UserId) -> Result<Option<SavedView>>; |
| 31 |
|
| 32 |
|
| 33 |
async fn update_position( |
| 34 |
&self, |
| 35 |
id: SavedViewId, |
| 36 |
user_id: UserId, |
| 37 |
position: i32, |
| 38 |
) -> Result<Option<SavedView>>; |
| 39 |
} |
| 40 |
|
| 41 |
|
| 42 |
#[async_trait] |
| 43 |
pub trait BackupSettingsRepository: Send + Sync { |
| 44 |
|
| 45 |
async fn get(&self, user_id: UserId) -> Result<Option<crate::models::BackupSettings>>; |
| 46 |
|
| 47 |
|
| 48 |
async fn upsert( |
| 49 |
&self, |
| 50 |
user_id: UserId, |
| 51 |
settings: crate::models::NewBackupSettings, |
| 52 |
) -> Result<crate::models::BackupSettings>; |
| 53 |
|
| 54 |
|
| 55 |
async fn update_last_backup_at(&self, user_id: UserId, timestamp: DateTime<Utc>) -> Result<()>; |
| 56 |
} |
| 57 |
|