#[derive(DatabaseSchema)]
{
// Attributes available to this derive:
#[tables]
}
Expand description
Generates a DatabaseSchema implementation that dispatches generic
DBMS operations to the correct concrete table types.
Given a struct annotated with #[tables(User = "users", Post = "posts")],
this macro produces:
impl<M: MemoryProvider> DatabaseSchema<M>with match-arm dispatch forselect,insert,delete,update,validate_insert,validate_update, andreferenced_tables.- An inherent
register_tablesmethod that registers all tables in a [DbmsContext].
§Example
ⓘ
#[derive(DatabaseSchema)]
#[tables(User = "users", Post = "posts")]
pub struct MySchema;
// Register tables during initialization:
MySchema::register_tables(&ctx)?;§Requirements
- Each type in the
#[tables(...)]attribute must implement [TableSchema]. - The generated types (
UserInsertRequest,UserUpdateRequest,UserRecord, etc.) must be in scope.