Crate crudcrate_derive

Crate crudcrate_derive 

Source
Expand description

Procedural macros for generating CRUD operations from Sea-ORM entities.

Main macro: #[derive(EntityToModels)] - see entity_to_models

Module guide: fields/ (field processing) | codegen/ (models, handlers, joins, routes)

Derive Macrosยง

EntityToModels
Generates complete CRUD API structures from Sea-ORM entities.
ToCreateModel
Generates <Name>Create struct with fields not excluded by exclude(create). Fields with on_create become Option<T> to allow user override. Implements From<NameCreate> for ActiveModel with automatic value generation.
ToListModel
Generates <Name>List struct with fields not excluded by exclude(list). Optimizes API payloads by excluding heavy fields (joins, large text) from list endpoints. Implements From<Name> and From<Model> conversions.
ToUpdateModel
Generates <Name>Update struct with fields not excluded by exclude(update). All fields are Option<Option<T>> to support partial updates and explicit null. Implements MergeIntoActiveModel trait with on_update expression handling.