Skip to main content

PrimaryKeyTrait

Trait PrimaryKeyTrait 

Source
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ยง

Required Methodsยง

Source

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".

Implementorsยง

Sourceยง

impl PrimaryKeyTrait for sea_orm::rbac::entity::permission::PrimaryKey

Available on crate feature rbac only.
Sourceยง

impl PrimaryKeyTrait for sea_orm::rbac::entity::resource::PrimaryKey

Available on crate feature rbac only.
Sourceยง

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.
Sourceยง

impl PrimaryKeyTrait for sea_orm::rbac::entity::role_permission::PrimaryKey

Available on crate feature rbac only.
Sourceยง

impl PrimaryKeyTrait for sea_orm::rbac::entity::user_override::PrimaryKey

Available on crate feature rbac only.
Sourceยง

impl PrimaryKeyTrait for sea_orm::rbac::entity::user_role::PrimaryKey

Available on crate feature rbac only.