aboutsummaryrefslogtreecommitdiff
path: root/src/infrastructure/persistence/models.rs
diff options
context:
space:
mode:
authorMikkel Thestrup <mikkel@mithe.dk>2026-01-27 17:07:13 +0100
committerMikkel Thestrup <mikkel@mithe.dk>2026-01-27 17:08:24 +0100
commitb35c8cca57811050536a4fa6c1cb5675453ad463 (patch)
tree622bce9ef4021701ab845fd88ff0fc86b47905aa /src/infrastructure/persistence/models.rs
parent4e78fd83349c95711cdee5acc56f248f81ebd25c (diff)
downloadkal-b35c8cca57811050536a4fa6c1cb5675453ad463.tar.gz
kal-b35c8cca57811050536a4fa6c1cb5675453ad463.zip
feat(infrastructure): implement SQLite persistence layer for calendar domain
Add infrastructure layer with SQLite repositories for calendars, events, and recurring events. Implements the repository pattern with proper domain/infrastructure separation. - Add CalendarModel, EventModel, RecurrenceModel, and RecurrenceExceptionModel for database persistence - Implement SqliteCalendarRepository with CRUD operations - Implement SqliteEventRepository with calendar filtering and time range queries - Implement SqliteRecurringEventRepository with exception handling and transactions - Add bidirectional mappers between domain entities and persistence models - Use sqlx query_as for type-safe database queries with FromRow derivation - Support upsert operations for all entities using ON CONFLICT clauses
Diffstat (limited to 'src/infrastructure/persistence/models.rs')
-rw-r--r--src/infrastructure/persistence/models.rs53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/infrastructure/persistence/models.rs b/src/infrastructure/persistence/models.rs
new file mode 100644
index 0000000..dc39e94
--- /dev/null
+++ b/src/infrastructure/persistence/models.rs
@@ -0,0 +1,53 @@
+use sqlx::FromRow;
+
+#[derive(Debug, FromRow)]
+pub struct CalendarModel {
+ pub id: String,
+ pub name: String,
+ pub description: Option<String>,
+ pub is_archived: i64,
+ pub created_at: String,
+ pub updated_at: String,
+}
+
+#[derive(Debug, FromRow)]
+pub struct EventModel {
+ pub id: String,
+ pub calendar_id: String,
+ pub title: String,
+ pub description: Option<String>,
+ pub starts_at: String,
+ pub ends_at: String,
+ pub color: i64,
+ pub is_all_day: i64,
+ pub is_cancelled: i64,
+ pub created_at: String,
+ pub updated_at: String,
+}
+
+#[derive(Debug, FromRow)]
+pub struct RecurrenceModel {
+ pub id: String,
+ pub calendar_id: String,
+ pub title: String,
+ pub description: Option<String>,
+ pub starts_at: String,
+ pub ends_at: String,
+ pub frequency: String,
+ pub interval: i64,
+ pub until: Option<String>,
+ pub color: i64,
+ pub is_all_day: i64,
+ pub is_cancelled: i64,
+ pub created_at: String,
+ pub updated_at: String,
+}
+
+#[derive(Debug, FromRow)]
+pub struct RecurrenceExceptionModel {
+ pub recurrence_id: String,
+ pub original_starts_at: String,
+ pub new_starts_at: Option<String>,
+ pub new_ends_at: Option<String>,
+ pub is_cancelled: i64,
+}