Skip to main content

Module schema

Module schema 

Source
Expand description

Schema definitions spanning the app layer, database layer, and the mapping between them. Schema representation for Toasty, split into three layers.

  • [app] – Model-level definitions: fields, relations, constraints. This is what the generated Rust code sees.
  • [db] – Table/column-level definitions. This is what the database sees.
  • [mapping] – Connects app fields to database columns, supporting non-1:1 mappings such as embedded structs and enums.

The top-level Schema struct ties all three layers together and is constructed via [Builder].

§Examples

use toasty_core::schema::{Schema, Builder};

let schema = Builder::new()
    .build(app_schema, &driver_capability)
    .expect("schema should be valid");

// Look up the database table backing a model
let table = schema.table_for(model_id);

Modules§

app
Application-level (model-oriented) schema definitions. Application-level schema definitions for models, fields, relations, and indices.
db
Database-level (table/column-oriented) schema definitions. Database-level schema definitions.
mapping
Mapping between the app layer and the database layer. Mapping between app-level models and database-level tables.

Structs§

Builder
Constructs a Schema from an app-level schema and driver capabilities.
Name
A multi-part identifier that can be rendered in various casing conventions.
Schema
The combined schema: app-level models, database-level tables, and the mapping that connects them.