pub trait PgEntity:
Send
+ Sync
+ Sized {
type Id: Send + Sync;
const TABLE: &'static str;
const COLUMNS: &'static [&'static str];
const PK_COLUMNS: &'static [&'static str];
const SCHEMA: &'static str = "default";
// Required methods
fn id(&self) -> Self::Id;
fn from_row(row: PgRow) -> Self;
}Expand description
Trait that defines entity metadata for database operations.
This trait is typically derived using #[derive(PgEntity)] from gearbox-rs-macros.
§Example
ⓘ
use gearbox_rs_macros::PgEntity;
#[derive(PgEntity)]
#[table("users")]
pub struct User {
#[primary_key]
pub id: String,
pub name: String,
pub email: String,
}Required Associated Constants§
Sourceconst COLUMNS: &'static [&'static str]
const COLUMNS: &'static [&'static str]
All column names that map to struct fields (excludes #[skip] fields)
Sourceconst PK_COLUMNS: &'static [&'static str]
const PK_COLUMNS: &'static [&'static str]
Primary key column name(s)
Provided Associated Constants§
Required Associated Types§
Required Methods§
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.