prax_schema

Macro prax_schema 

Source
prax_schema!() { /* proc-macro */ }
Expand description

Generate models from a Prax schema file.

This macro reads a .prax schema file at compile time and generates type-safe Rust code for all models, enums, and types defined in the schema.

§Example

prax::prax_schema!("schema.prax");

// Now you can use the generated types:
let user = client.user().find_unique(user::id::equals(1)).exec().await?;

§Generated Code

For each model in the schema, this macro generates:

  • A module with the model name (snake_case)
  • A Data struct representing a row from the database
  • A CreateInput struct for creating new records
  • A UpdateInput struct for updating records
  • Field modules with filter operations (equals, contains, in_, etc.)
  • A WhereParam enum for type-safe filtering
  • An OrderByParam enum for sorting
  • Select and Include builders for partial queries