pub trait PrimaryKeyTrait: IdenStatic + Iterable {
type ValueType: Sized + Send + Debug + PartialEq + IntoValueTuple + FromValueTuple + TryGetableMany + TryFromU64;
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
source
type ValueType: Sized + Send + Debug + PartialEq + IntoValueTuple + FromValueTuple + TryGetableMany + TryFromU64
Required Methods
sourcefn auto_increment() -> bool
fn auto_increment() -> bool
Method to call to perform AUTOINCREMENT
operation on a Primary Kay