aboutsummaryrefslogtreecommitdiffstats
path: root/lib/api-config/src/schema/get_schema.rs
blob: 427a02feb3481a2930256ea527f286fe4b368e87 (plain)
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
use tracing::debug;

use crate::{
    ConfigurationError,
    schema::{SchemaService, TransactionSchema},
};

pub(super) async fn get_schema(
    state: &SchemaService,
    kind: &str,
    version: &str,
) -> Result<Option<TransactionSchema>, ConfigurationError> {
    debug!("getting transaction schema");
    let result = sqlx::query_as!(
        TransactionSchema,
        "select 
            *
            from transaction_schema where schema_type = $1 and schema_version = $2",
        kind,
        version,
    )
    .fetch_optional(&state.database)
    .await?;

    Ok(result)
}