Crate sea_orm_newtype
source ·Expand description
sea-orm-newtype
This crate provides helper derive macro to implement new-type pattern for sea-orm.
Example
use std::marker::PhantomData;
use uuid::Uuid;
use sea_orm_newtype::DeriveNewType;
/// New type for id that has specific type.
#[derive(Debug, Clone, PartialEq, DeriveNewType)]
#[sea_orm_newtype(from_into = "Uuid", primary_key)]
pub struct Id<T>(Uuid, PhantomData<T>);
impl<T> From<Uuid> for Id<T> {
fn from(id: Uuid) -> Id<T> {
Id(id, PhantomData)
}
}
impl<T> From<Id<T>> for Uuid {
fn from(value: Id<T>) -> Self {
value.0
}
}
Re-exports
pub use sea_orm;
pub use sea_orm::sea_query;
Enums
- Value variants
Traits
- Try to convert a type to a u64
- An interface to get a value from the query result
Derive Macros
- derive macro to implement new-type pattern for sea-orm. Derive some traits to use in sea-orm. By default, the following traits are implemented.