Skip to main content

systemprompt_content/repository/
mod.rs

1//! Content persistence: SQL-backed repositories for content, links, and search.
2//!
3//! [`ContentRepository`] owns content rows; [`LinkRepository`] and
4//! [`LinkAnalyticsRepository`] own campaign links and their click analytics;
5//! [`SearchRepository`] backs full-text queries. All access goes through
6//! compile-time-verified query macros.
7//!
8//! Copyright (c) systemprompt.io — Business Source License 1.1.
9//! See <https://systemprompt.io> for licensing details.
10
11pub mod content;
12pub mod link;
13pub mod search;
14
15pub use content::ContentRepository;
16pub use link::{LinkAnalyticsRepository, LinkRepository};
17pub use search::SearchRepository;
18
19use crate::error::ContentError;
20use systemprompt_database::DbPool;
21
22#[derive(Debug, Clone)]
23pub struct ContentRepositories {
24    pub content: ContentRepository,
25    pub search: SearchRepository,
26    pub link: LinkRepository,
27    pub link_analytics: LinkAnalyticsRepository,
28}
29
30impl ContentRepositories {
31    pub fn new(db: &DbPool) -> Result<Self, ContentError> {
32        Ok(Self {
33            content: ContentRepository::new(db)?,
34            search: SearchRepository::new(db)?,
35            link: LinkRepository::new(db)?,
36            link_analytics: LinkAnalyticsRepository::new(db)?,
37        })
38    }
39}