logo

Trait sea_orm::entity::prelude::PrimaryKeyTrait[][src]

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

Associated Types

Required methods

Method to call to perform AUTOINCREMENT operation on a Primary Kay

Implementors