[][src]Trait elephantry::Model

pub trait Model<'a> {
    type Entity: Entity;
    type Structure: Structure;
    pub fn new(connection: &'a Connection) -> Self;

    pub fn default_projection() -> Projection { ... }
pub fn create_projection() -> Projection { ... }
pub fn create_entity(tuple: &Tuple<'_>) -> Self::Entity { ... }
pub fn primary_key(
        entity: &Self::Entity
    ) -> HashMap<&'static str, &dyn ToSql> { ... } }

Impl this trait to create a link between an entity and a structure.

Associated Types

Loading content...

Required methods

pub fn new(connection: &'a Connection) -> Self[src]

Loading content...

Provided methods

pub fn default_projection() -> Projection[src]

This method creates a projection based on the structure definition of the underlying relation.

This method can be used where a projection that sticks to table definition is needed like recursive CTEs. For normal projections, use create_projection instead.

pub fn create_projection() -> Projection[src]

This is a helper to create a new projection according to the current structure. Overriding this method will change projection for all models.

pub fn create_entity(tuple: &Tuple<'_>) -> Self::Entity[src]

Create a new entity.

pub fn primary_key(entity: &Self::Entity) -> HashMap<&'static str, &dyn ToSql>[src]

Loading content...

Implementors

Loading content...