command
Version:
v0.5.0
Opens a new window with list of versions in this module.
Published: Feb 9, 2026
License: MIT
Opens a new window with license information.
Imports: 7
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
Advanced Example - Custom Types & Prepared Queries
This example demonstrates db-catalyst's unique features that sqlc doesn't have.
Features Demonstrated
- Custom Types with Pointer Control - Map SQLite types to custom Go types
- Schema Transformation - Use domain types in SQL, get Go types in code
- Prepared Queries - Pre-compiled statements with metrics
- Type Safety - Strongly typed IDs and enums
Custom Types
// Your domain types
type UserID int64
type Status string
type Money int64 // stored as cents
Map them in config:
[[custom_types.mapping]]
custom_type = "user_id"
sqlite_type = "INTEGER"
go_type = "github.com/electwix/db-catalyst/examples/advanced/types.UserID"
pointer = false
Running
cd examples/advanced
db-catalyst
go run main.go
What Makes This Special
- Type Safety: Can't accidentally pass a ProductID where UserID expected
- Pointer Control: Explicit
pointer = true/false regardless of nullability
- Prepared Statements: Metrics and thread-safe initialization
- Schema Stays Clean: Use custom types in SQL, they transform automatically
Documentation
¶
There is no documentation for this package.
Source Files
¶
Directories
¶
|
|
|
Package types provides domain types for the advanced example.
|
Package types provides domain types for the advanced example. |
Click to show internal directories.
Click to hide internal directories.