Derive Macro Repository

Source
#[derive(Repository)]
{
    // Attributes available to this derive:
    #[mongo]
    #[postgres]
}
Expand description

Provides an implementation of RepositoryAccess<C> depending on the provided attributes.

Accepted attributes and fields are:

#[postgres(Connection)] -> postgres,

#[mongo(Connection)] -> mongo,

The attributes for the client connections must be specified and equal to a generic connection parameter of the repository, e.g. if a generic connection is specified as C then the attribute must be either #[postgres(C)] or #[mongo(C)] and will be concretised to the designated client connection.

Deriving structs MUST have a postgres, mongo or both fields and they must be a generic client Client<A, C> provided in hextacy::clients::db.

#[derive(Debug, Repository)]
#[postgres(Connection)]
pub(super) struct Repository<C, Connection, User>
  where
    C: DBConnect<Connection = Connection>,
    User: UserRepository<Connection>
 {
    postgres: Client<C, Connection>,
    user: PhantomData<User>
 }