glimr/db/gen


Database Code Generator

Generates typed Gleam code from schema definitions and SQL query files. Scans src/data/models/ for model directories, reads schema definitions and SQL queries, and generates repository modules with type-safe database functions.

Each model directory should contain:

Generated code is written to {model}/gen/{model}_repository.gleam and automatically formatted with gleam format.

Run with: gleam run -m glimr/db/gen

Values

pub fn main() -> Nil

Main

Entry point for the code generator CLI. Runs code generation for all models. Run with: gleam run -m glimr/db/gen

pub fn run(model_filter: option.Option(List(String))) -> Nil

Run

Runs code generation with an optional model filter. When a filter is provided, only models in the list are processed. Pass None to generate code for all models.


Example:

// Generate all models
gen.run(None)

// Generate only specific models
gen.run(Some(["user", "post"]))
Search Document