sofie-db 0.2.0

The handler model (inputs, events, replies), aggregates, read models, the query builder, the unit of work, migrations, the worker and the database seam.
Documentation
use sofie_core::{Error, Result};

use crate::{Aggregate, Id, Query, Read, Source};

pub trait Select: Source {
    #[must_use]
    fn query() -> Query<Self> {
        Query::default()
    }
}

impl<T: Source> Select for T {}

pub trait Load: Aggregate {
    fn find(read: &Read, id: Id<Self>) -> impl Future<Output = Result<Self>> + Send {
        async move {
            Self::query()
                .where_(Self::ID.eq(id))
                .first(read)
                .await?
                .ok_or(Error::NotFound)
        }
    }
}

impl<A: Aggregate> Load for A {}