examples/

directory
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: MIT

README

Examples

This directory contains examples demonstrating db-catalyst features.

Examples

simple - Basic CRUD
  • Basic CREATE TABLE
  • Simple SELECT/INSERT/UPDATE/DELETE
  • Named queries with :one, :many, :exec
  • Nullable fields
complex - Advanced SQL
  • Many-to-many relationships
  • CTEs (Common Table Expressions)
  • JOINs and aggregations
  • Complex queries with subqueries
advanced - Custom Types & Prepared Queries
  • Custom types with pointer control (unique to db-catalyst)
  • Schema transformation (unique to db-catalyst)
  • Prepared queries with metrics (unique to db-catalyst)
  • Type-safe domain modeling

Running Examples

Each example can be run independently:

cd examples/simple
go generate ./...
go run main.go

Or use the db-catalyst CLI directly:

cd examples/simple
db-catalyst
go run main.go

What Makes These Examples Special

Unlike sqlc examples, these demonstrate db-catalyst's unique features:

  1. Grammar-driven parsing - Clean, extensible architecture
  2. Custom type system - Map SQLite types to domain types
  3. Schema transformation - Use domain types in SQL
  4. Modern Go - Context-first, clean structs, no interfaces

Directories

Path Synopsis
db
cache_example
db
db
mysql
db
postgresql
db
Command split_models demonstrates the optional models-package split, where the generated table-model structs live in their own Go sub-package (.../db/models) that the main querier package and application code import.
Command split_models demonstrates the optional models-package split, where the generated table-model structs live in their own Go sub-package (.../db/models) that the main querier package and application code import.
db

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL