Expand description
#[derive(Model)]: the day-persistence derive (docs/persistence.md).
Model implies Observable and adds the schema half: impl day_persistence::Model with
the table name, column list, row↔struct mappers and the default row, typed column
references for predicates (Trip::name()), and the relation accessors and wiring.
#[model(id)] marks the key; field options are column = "…", unique, index,
transient (observable, never stored), with = Codec, json, relation(…) and
link(…); struct options are table = "…", external = "alias", index("a", "b") for
composites, fts(…) and spatial(…). #[obs(skip)] leaves a field out of both halves: a
field the change log cannot name could never mark its row dirty, so persisting it would
silently lose edits.
The observable half is not generated here. The derive describes the struct to day-macros’
observable_impls! (reached as day_persistence::__observable_impls!), which emits exactly
what #[derive(Observable)] would for the same fields. That one macro is the whole
contract between this derive and the framework’s: this crate owns the #[model(…)] grammar
and the schema emission, day-macros owns the accessors, and neither reads the other’s
attributes.
Generated paths say day_persistence::… and day_model::… unqualified. An app that derives
Model depends on day-persistence directly, which resolves the first; use day::prelude::* with the facade’s model feature (or a direct day-model dependency)
resolves the second.
Same construction as day-macros, with neither syn nor quote. A derive that needs field names and type tokens never has to understand a type, only re-emit it.
Derive Macros§
- Model
- A persistable model: everything
#[derive(Observable)]generates, plusimpl day_persistence::Model: table name, column list, row↔struct mappers and the default row. See day-persistence’s crate docs anddocs/persistence.md.