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

Describes the primary key of an entity: which column variants make it up, the Rust value type (a tuple for composite keys), and whether the database auto-generates it.

Usually generated by #[derive(DerivePrimaryKey)] or implied by the #[sea_orm(primary_key)] attribute on Model fields. Manual impls look like:

use sea_orm::entity::prelude::*;

#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)]
pub enum PrimaryKey {
    Id,
}

impl PrimaryKeyTrait for PrimaryKey {
    type ValueType = i32;
    fn auto_increment() -> bool { true }
}

Required Associated Types§

Source

type ValueType: Sized + Debug + PartialEq + IntoValueTuple + FromValueTuple + TryGetableMany + TryFromU64 + PrimaryKeyArity

Rust type of the primary-key value. A single column is its own type (e.g. i32); composite keys use a tuple (e.g. (i32, String)).

Required Methods§

Source

fn auto_increment() -> bool

true if the database generates the primary key (e.g. SERIAL / IDENTITY / AUTOINCREMENT). Auto-increment keys can be left as NotSet on insert.

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.