pub trait PrimaryKeyTrait: IdenStatic + Iterable {
type ValueType: Sized + Debug + PartialEq + IntoValueTuple + FromValueTuple + TryGetableMany + TryFromU64 + PrimaryKeyArity;
// Required method
fn auto_increment() -> bool;
}Expand description
A Trait for to be used to define a Primary Key.
A primary key can be derived manually
ยงExample
use sea_orm::entity::prelude::*;
#[derive(Copy, Clone, Debug, EnumIter)]
pub enum PrimaryKey {
Id,
}
impl PrimaryKeyTrait for PrimaryKey {
type ValueType = i32;
fn auto_increment() -> bool {
true
}
}Alternatively, use derive macros to automatically implement the trait for a Primary Key
ยงExample
use sea_orm::entity::prelude::*;
#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)]
pub enum PrimaryKey {
Id,
}See module level docs crate::entity for a full example
Required Associated Typesยง
type ValueType: Sized + Debug + PartialEq + IntoValueTuple + FromValueTuple + TryGetableMany + TryFromU64 + PrimaryKeyArity
Required Methodsยง
Sourcefn auto_increment() -> bool
fn auto_increment() -> bool
Method to call to perform AUTOINCREMENT operation on a Primary Key
Dyn Compatibilityยง
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementorsยง
Sourceยงimpl PrimaryKeyTrait for sea_orm::rbac::entity::permission::PrimaryKey
Available on crate feature rbac only.
impl PrimaryKeyTrait for sea_orm::rbac::entity::permission::PrimaryKey
Available on crate feature
rbac only.type ValueType = PermissionId
Sourceยงimpl PrimaryKeyTrait for sea_orm::rbac::entity::resource::PrimaryKey
Available on crate feature rbac only.
impl PrimaryKeyTrait for sea_orm::rbac::entity::resource::PrimaryKey
Available on crate feature
rbac only.type ValueType = ResourceId
Sourceยงimpl PrimaryKeyTrait for sea_orm::rbac::entity::role::PrimaryKey
Available on crate feature rbac only.
impl PrimaryKeyTrait for sea_orm::rbac::entity::role::PrimaryKey
Available on crate feature
rbac only.Sourceยงimpl PrimaryKeyTrait for sea_orm::rbac::entity::role_hierarchy::PrimaryKey
Available on crate feature rbac only.
impl PrimaryKeyTrait for sea_orm::rbac::entity::role_hierarchy::PrimaryKey
Available on crate feature
rbac only.Sourceยงimpl PrimaryKeyTrait for sea_orm::rbac::entity::role_permission::PrimaryKey
Available on crate feature rbac only.
impl PrimaryKeyTrait for sea_orm::rbac::entity::role_permission::PrimaryKey
Available on crate feature
rbac only.type ValueType = (RoleId, PermissionId, ResourceId)
Sourceยงimpl PrimaryKeyTrait for sea_orm::rbac::entity::user_override::PrimaryKey
Available on crate feature rbac only.
impl PrimaryKeyTrait for sea_orm::rbac::entity::user_override::PrimaryKey
Available on crate feature
rbac only.type ValueType = (UserId, PermissionId, ResourceId)
Sourceยงimpl PrimaryKeyTrait for sea_orm::rbac::entity::user_role::PrimaryKey
Available on crate feature rbac only.
impl PrimaryKeyTrait for sea_orm::rbac::entity::user_role::PrimaryKey
Available on crate feature
rbac only.