Defines the correspondence between app-level models and database-level
tables.
The mapping is constructed during schema building and remains immutable at
runtime. It provides the translation layer that enables the query engine to
convert model-oriented statements into table-oriented statements during the
lowering phase.
use toasty_core::schema::mapping::Mapping;
use indexmap::IndexMap;
let mapping = Mapping { models: IndexMap::new() };
assert_eq!(mapping.models.len(), 0);
A document column’s db::Column is typed
by the structural stmt::Type::Object — the column does not know
which embedded model it stores. That knowledge normally travels inside
the mapping’s cast expressions (model_to_table carries the lowering
cast, table_to_model the raising cast); this index covers the
operations that bypass those templates — an Append assignment’s
operand cast during statement lowering.
Returns the app-level type of a #[document] column — Type::Model
for a bare embed, List(Model) for an embed collection — or None if
the column does not store a document.