pub trait EntityBase: 'static + Sized {
type ConnectionType: for<'a> DatabaseConnection<'a>;
type AutoGeneratedFields: Default;
const COLLECTION_NAME: &'static str;
// Required method
fn to_transaction_entity(self) -> Entity;
// Provided methods
fn downcast<T: EntityBase>(&self) -> Option<&T> { ... }
fn downcast_arc<T>(self: Arc<Self>) -> Option<Arc<T>>
where Self: Send + Sync,
T: EntityBase + Send + Sync { ... }
}Expand description
A supertrait that all entities must implement. This handles multiplexing over the two different database backends.
This trait should be removed once the persistence layers are unified. See WPB-16241.
Required Associated Constants§
Sourceconst COLLECTION_NAME: &'static str
const COLLECTION_NAME: &'static str
Beware: if you change the value of this constant on any WASM entity, you’ll need to do a data migration not only because it is used as reference to the object store names but also for the value of the aad.
Required Associated Types§
type ConnectionType: for<'a> DatabaseConnection<'a>
Sourcetype AutoGeneratedFields: Default
type AutoGeneratedFields: Default
Entities which implement EntityDatabaseMutation have a pre_save method which might generate or
update some fields of the item. The canonical example is an updated_at field.
This type must contain a copy of each modification to the item, so that the caller of a .save(entity)
function can know what has changed and what the new values are.
Required Methods§
fn to_transaction_entity(self) -> Entity
Provided Methods§
fn downcast<T: EntityBase>(&self) -> Option<&T>
fn downcast_arc<T>(self: Arc<Self>) -> Option<Arc<T>>
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.