Skip to main content

EntityRepoMeta

Trait EntityRepoMeta 

Source
pub trait EntityRepoMeta {
    // Required methods
    fn column_types() -> HashMap<String, String>;
    fn search_fields() -> &'static [&'static str];

    // Provided methods
    fn private_fields() -> &'static [&'static str] { ... }
    fn owner_field() -> Option<&'static str> { ... }
    fn company_field() -> Option<&'static str> { ... }
    fn relations() -> &'static [(&'static str, &'static str, &'static str)] { ... }
}
Expand description

Metadata trait that entities implement so GenericCrudRepository can provide list_paginated_filtered and list_deleted_filtered without per-entity boilerplate.

Generated once per entity by the rust generator.

MethodPurpose
column_typesPostgreSQL cast hints (e.g. {"id": "uuid"})
search_fieldsText columns searched with ILIKE

Required Methods§

Source

fn column_types() -> HashMap<String, String>

PostgreSQL type hints for filter/sort (e.g. {"id": "uuid"}).

Source

fn search_fields() -> &'static [&'static str]

Text columns to include in full-text / ILIKE search.

Provided Methods§

Source

fn private_fields() -> &'static [&'static str]

Response fields visible only to the row owner and platform/root callers (@private). Stripped for everyone else.

Source

fn owner_field() -> Option<&'static str>

The response field (camelCase) holding the owner/company id (@owner), compared against the caller’s access scope to decide private-field visibility. None = the entity has no owner concept.

Source

fn company_field() -> Option<&'static str>

The DB column that scopes rows to a company (snake_case, e.g. company_id). None = the entity is global (reference data) and is not fenced.

The generator emits this structurally — from the presence of the company column, a fact it cannot forget — and an entity opts OUT with @global. The polarity is deliberate: owner_field() above is opt-IN via @owner, and in a year of generated entities not one model ever declared it, so the whole field-security path silently never ran. Security that must be remembered, in a file nobody edits for security reasons, defaults to open and stays open. Here silence means fenced, and forgetting is the safe direction.

This is a row-visibility fence, the same category as SoftDelete’s unconditional deleted_at IS NULL — not domain logic.

Source

fn relations() -> &'static [(&'static str, &'static str, &'static str)]

To-one relations expandable via ?include=<name>, as (relation_name, target_table, local_fk_field) — all response keys (relation_name/local_fk in camelCase; target_table is the DB table). Default: none.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§