1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//! Persistence Layer - Reusable Repository Implementations
//!
//! This module provides generic, reusable repository implementations that can be
//! used across all modules in the framework. Instead of writing custom repositories
//! for each entity, modules can use these generic implementations.
//!
//! # Available Implementations
//!
//! - `InMemoryRepository` - Thread-safe in-memory storage (testing, prototyping)
//! - `PostgresRepository` - PostgreSQL-backed storage (production, requires "postgres" feature)
//!
//! # Usage Pattern
//!
//! ## In-Memory (testing/prototyping)
//!
//! ```ignore
//! use backbone_core::persistence::{InMemoryRepository, PersistentEntity, CrudRepository};
//!
//! #[derive(Clone, Debug, Serialize, Deserialize)]
//! struct User {
//! id: String,
//! name: String,
//! created_at: Option<DateTime<Utc>>,
//! updated_at: Option<DateTime<Utc>>,
//! deleted_at: Option<DateTime<Utc>>,
//! }
//!
//! impl PersistentEntity for User { /* ... */ }
//!
//! let repo = InMemoryRepository::<User>::new();
//! let user = repo.create(user).await?;
//! ```
//!
//! ## PostgreSQL (production)
//!
//! ```ignore
//! use backbone_core::persistence::{PostgresRepository, PostgresEntity, PersistentEntity};
//! use sqlx::FromRow;
//!
//! #[derive(Clone, Debug, Serialize, Deserialize, FromRow)]
//! struct User {
//! id: String,
//! name: String,
//! created_at: Option<DateTime<Utc>>,
//! updated_at: Option<DateTime<Utc>>,
//! deleted_at: Option<DateTime<Utc>>,
//! }
//!
//! impl PersistentEntity for User { /* ... */ }
//!
//! impl PostgresEntity for User {
//! fn table_name() -> &'static str { "users" }
//! fn select_columns() -> &'static [&'static str] {
//! &["id", "name", "created_at", "updated_at", "deleted_at"]
//! }
//! fn insert_columns() -> &'static [&'static str] {
//! &["id", "name", "created_at", "updated_at"]
//! }
//! fn bind_for_insert<'q>(entity: &Self, query: Query<'q, ...>) -> Query<'q, ...> {
//! query.bind(&entity.id).bind(&entity.name)
//! .bind(entity.created_at).bind(entity.updated_at)
//! }
//! }
//!
//! let pool = PgPool::connect("...").await?;
//! let repo = PostgresRepository::<User>::new(pool);
//! let user = repo.create(user).await?;
//! ```
// Re-exports from traits
pub use ;
// Re-export InMemoryRepository
pub use InMemoryRepository;
// Re-export CrudServiceAdapter for bridging Repository to CrudService
pub use ;
// Re-export PostgreSQL types when feature is enabled
pub use ;
pub use PostgresEntity;