Expand description
Macros: the derive macros that generate entity, relation, identifier and row-decoding impls for turso-orm.
The macros are re-exported by turso_orm behind its macros feature
and by turso_orm_migration; they are not meant to be used from this
crate directly, because the code they expand to refers to
::turso_orm::... paths and to the __private module that crate
exposes for generated code only.
Each derive lives in its own module with a single expand function that
takes the parsed input and returns either the generated tokens or a
syn::Error carrying the span of the offending item, so that users see
the error on their own code rather than inside the macro. Attribute
parsing is shared through the attrs module.
DeriveEntityModelexpands aModelstruct intoEntity,Column,PrimaryKeyandActiveModelplus their trait impls.DeriveRelationexpands aRelationenum intoRelationTraitandRelated<R>impls, junction tables included.DeriveActiveEnummakes a fieldless enum a column type.DerivePartialModelmakes a struct a self-selecting projection.DeriveIntoActiveModelconverts a plain struct into an active model.DeriveIdenimplements the identifier traits on a unit struct or a fieldless enum.FromQueryResultimplements row decoding for a plain struct.DeriveMigrationNamenames a migration after its module.
Derive Macros§
- Derive
Active Enum - Derives
ActiveEnumand the column-type impls for a fieldless enum. - Derive
Entity Model - Derives an entity from a
Modelstruct. - Derive
Iden - Derives
IdenStaticand the SQL identifier traits for a unit struct or a fieldless enum. - Derive
Into Active Model - Derives
IntoActiveModelfor a plain struct whose fields are a subset of an entity’s columns. - Derive
Migration Name - Derives
MigrationNamefrom the module path. - Derive
Partial Model - Derives
PartialModelTraitandFromQueryResultfor a projection struct. - Derive
Relation - Derives
RelationTraitandRelated<R>impls from aRelationenum. - From
Query Result - Derives
FromQueryResultfor a plain struct.