glimr/db/gen/generator
Code Generator
Generates typed Gleam repository modules from parsed schema definitions and SQL query files. Produces complete, formatted Gleam code including:
- Model type definitions matching the schema
- Decoder functions for database rows
- Query functions for each SQL file (with _or variants)
- Row types for queries with custom SELECT columns
Values
pub fn generate(
model_name: String,
table: schema_parser.Table,
queries: List(#(String, String, parser.ParsedQuery)),
) -> String
Generate
Generates a complete Gleam repository module for a model. Combines the header, imports, model type, decoder, and all query functions into a single module string.