use es_entity::*;
use sqlx::PgPool;
use crate::primitives::{JournalId, TransactionId, TxTemplateId};
use super::entity::*;
#[derive(EsRepo, Clone)]
#[es_repo(
entity = "Transaction",
columns(
external_id(ty = "Option<String>", update(persist = false)),
// No `find_by`: nothing looks a transaction up by correlation id, and
// the index that would back it was dropped from the migration.
correlation_id(ty = "String", update(persist = false), find_by = false),
journal_id(ty = "JournalId", update(persist = false)),
tx_template_id(ty = "TxTemplateId", update(persist = false), list_for(by(created_at))),
effective(ty = "chrono::NaiveDate", update(persist = false)),
),
tbl_prefix = "cala",
persist_event_context = false
)]
pub(super) struct TransactionRepo {
pool: PgPool,
}
impl TransactionRepo {
pub fn new(pool: &PgPool) -> Self {
Self { pool: pool.clone() }
}
}