pub trait Record:
Sized
+ Send
+ Sync
+ 'static {
type Entity: EntityTrait;
type ActiveModel: ActiveModelTrait<Entity = Self::Entity> + ActiveModelBehavior + Send + 'static;
// Required methods
fn from_model(model: <Self::Entity as EntityTrait>::Model) -> Self;
fn into_active_model_full(&self) -> Self::ActiveModel;
fn into_active_model(&self) -> Self::ActiveModel;
fn apply_auto_fields(am: &mut Self::ActiveModel, is_insert: bool);
// Provided methods
fn find_all(
db: &impl ConnectionTrait,
) -> impl Future<Output = Result<Vec<Self>, Error>> + Send
where <Self::Entity as EntityTrait>::Model: FromQueryResult + Send + Sync,
Self: From<<Self::Entity as EntityTrait>::Model> { ... }
fn query() -> EntityQuery<Self, Self::Entity>
where <Self::Entity as EntityTrait>::Model: FromQueryResult + Send + Sync,
Self: From<<Self::Entity as EntityTrait>::Model> { ... }
fn update_many() -> EntityUpdateMany<Self::Entity> { ... }
fn delete_many() -> EntityDeleteMany<Self::Entity> { ... }
}Expand description
Core trait for domain model types backed by a database table.
The #[modo_db::entity] macro generates an implementation of this trait
for each entity struct. It provides CRUD operations and query builders.
Most methods are macro-generated (not default impls) because they need either PK-specific signatures or concrete type context for hook resolution.
Required Associated Types§
type Entity: EntityTrait
type ActiveModel: ActiveModelTrait<Entity = Self::Entity> + ActiveModelBehavior + Send + 'static
Required Methods§
Sourcefn from_model(model: <Self::Entity as EntityTrait>::Model) -> Self
fn from_model(model: <Self::Entity as EntityTrait>::Model) -> Self
Convert a SeaORM model to the domain type.
Sourcefn into_active_model_full(&self) -> Self::ActiveModel
fn into_active_model_full(&self) -> Self::ActiveModel
Convert to an active model with ALL fields set.
Sourcefn into_active_model(&self) -> Self::ActiveModel
fn into_active_model(&self) -> Self::ActiveModel
Convert to an active model with only PK fields set (rest NotSet).
Sourcefn apply_auto_fields(am: &mut Self::ActiveModel, is_insert: bool)
fn apply_auto_fields(am: &mut Self::ActiveModel, is_insert: bool)
Fill auto-generated fields (ID, timestamps) on an active model.
Provided Methods§
Sourcefn find_all(
db: &impl ConnectionTrait,
) -> impl Future<Output = Result<Vec<Self>, Error>> + Sendwhere
<Self::Entity as EntityTrait>::Model: FromQueryResult + Send + Sync,
Self: From<<Self::Entity as EntityTrait>::Model>,
fn find_all(
db: &impl ConnectionTrait,
) -> impl Future<Output = Result<Vec<Self>, Error>> + Sendwhere
<Self::Entity as EntityTrait>::Model: FromQueryResult + Send + Sync,
Self: From<<Self::Entity as EntityTrait>::Model>,
Fetch all records.
Sourcefn query() -> EntityQuery<Self, Self::Entity>where
<Self::Entity as EntityTrait>::Model: FromQueryResult + Send + Sync,
Self: From<<Self::Entity as EntityTrait>::Model>,
fn query() -> EntityQuery<Self, Self::Entity>where
<Self::Entity as EntityTrait>::Model: FromQueryResult + Send + Sync,
Self: From<<Self::Entity as EntityTrait>::Model>,
Start a chainable query builder.
Sourcefn update_many() -> EntityUpdateMany<Self::Entity>
fn update_many() -> EntityUpdateMany<Self::Entity>
Start a bulk UPDATE builder.
Sourcefn delete_many() -> EntityDeleteMany<Self::Entity>
fn delete_many() -> EntityDeleteMany<Self::Entity>
Start a bulk DELETE builder.
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.