pub trait Key {
    type Entity;

    fn columns() -> Vec<String>;
    fn default_inverse_columns() -> Vec<String>;
    fn params(&self) -> Vec<SqlArg>;

    fn unaliased_predicate_expr(&self) -> SqlExpr { ... }
}
Expand description

Trait to provide the entity type for a key. This is only used for ergonomics of the api.

Required Associated Types

Required Methods

Return primary key columns for a given entity.

Return foreign key columns that match the primary keys for a given entity. This is only needed to merge entities. The names are calculated and do not necessarily match the actual foreign keys on the other table. The translation rules are (for snake case column format):

TypeGuessing ruleExample
Normal fieldstablename + normal fieldid -> user_id, access_code -> user_access_code
JoinsNo changelanguage_id -> language_id

If the automatic generated names are not correct, the user is required to correct them by attributing the relevant field with

#[toql( merge( columns( self = "id", other = "user_code")))]

Return key values as params. Useful to loop across a composite key.

Provided Methods

Implementors