pub trait Model:
Sized
+ Send
+ Sync
+ Unpin
+ 'static{
type PrimaryKey: Type<Postgres> + for<'q> Encode<'q, Postgres> + Send + Sync + Clone + 'static;
const TABLE: &'static str;
const COLUMNS: &'static [&'static str];
const SOFT_DELETES: bool = false;
const PK_COLUMN: &'static str = "id";
// Required method
fn primary_key(&self) -> &Self::PrimaryKey;
// Provided methods
fn query() -> QueryBuilder<Self> { ... }
fn find(
pool: &PgPool,
id: Self::PrimaryKey,
) -> BoxFuture<'_, Result<Option<Self>, Error>> { ... }
fn all(pool: &PgPool) -> BoxFuture<'_, Result<Vec<Self>, Error>> { ... }
}Required Associated Constants§
Provided Associated Constants§
Sourceconst SOFT_DELETES: bool = false
const SOFT_DELETES: bool = false
When true, the query builder automatically applies a deleted_at IS NULL
filter to Model::query(). Set via #[soft_deletes] on the struct.
Required Associated Types§
type PrimaryKey: Type<Postgres> + for<'q> Encode<'q, Postgres> + Send + Sync + Clone + 'static
Required Methods§
Sourcefn primary_key(&self) -> &Self::PrimaryKey
fn primary_key(&self) -> &Self::PrimaryKey
Return this row’s primary key.
Provided Methods§
Sourcefn query() -> QueryBuilder<Self>
fn query() -> QueryBuilder<Self>
Start a new query builder for this model.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".