Mixins
Mixins provide field reuse for.cstack models. They are a schema authoring convenience, not a
runtime inheritance feature.
Syntax
Declare a top-levelmixin block and apply it inside a model with @use(...).
Semantics
CrateStack expands mixin fields into the model before semantic validation and before Rust, Dart, and TypeScript code generation. That means:- generated clients and generated server code see normal model fields after expansion
- validator rules run on the expanded model field set
- mixins do not create a separate generated runtime type
Rules
Current mixin support is intentionally narrow:- mixins are only supported as top-level declarations
@use(...)is only supported insidemodelblocks- mixins contain fields, not model-level attributes
- mixins must not declare
@id - model-local fields win on name conflicts with mixin fields
createdAt DateTime? definition wins.
Non-goals
Mixins are not:- polymorphism
- inheritance between generated model types
- a way to share model
@@...attributes - a way to declare shared primary keys