pub mod base;
pub mod cache;
pub mod connectors;
pub mod query;
pub mod repository;
pub mod seed;
pub mod types_extra;
pub use base::{BaseAuditableEntity, BaseEntity};
pub use query::{DeleteQueryData, NoUser, PageResult, QueryData, RepositoryOptions};
pub use repository::PersistentRepository;
pub use seed::{DatabaseSeeder, DatabaseSeederRunner, entity as seeder_entity};
pub use types_extra::{
ChangeResultModel, EntityProjection, PaginatedResult as PaginatedResultAlias, Position,
};
#[macro_export]
macro_rules! active_enum {
($name:ident, $pg_name:literal, $( $(#[$meta:meta])* $variant:ident => $value:literal),+ $(,)?) => {
#[derive(Copy, Clone, Debug, PartialEq, Eq, schemars::JsonSchema, sea_orm::entity::prelude::EnumIter, sea_orm::entity::prelude::DeriveActiveEnum, serde::Serialize, serde::Deserialize)]
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = $pg_name, rename_all= "SCREAMING_SNAKE_CASE")]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
#[doc = concat!("An enum representing a database type that is best represented as an enumeration of string values which is named `", stringify!($name), "`.")]
pub enum $name {
$(
$(#[$meta])*
$variant,
)+
}
impl $name {
#[doc = concat!("Returns a vector of all variants of the `", stringify!($name), "` enum.")]
pub fn variants() -> Vec<Self> {
vec![
$(Self::$variant),+
]
}
#[doc = concat!("Returns the string value associated with the `", stringify!($name), "` enum variant.")]
pub fn value(&self) -> String {
match self {
$(Self::$variant => $value.to_string()),+
}
}
#[doc = concat!("Returns an `Option<", stringify!($name), ">` corresponding to the provided string value. If the value does not match any variant, `None` is returned.")]
pub fn from_value(value: String) -> Option<Self> {
Self::variants().into_iter().find(|variant| variant.value() == value)
}
}
};
}