internals

command
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Example: internals

Shows what drel's codegen produces under the hood. Everything here — ModelMeta, Scan, Snapshot, Diff, column references — is normally generated into <model>_drel.go files. This example hand-crafts them so you can see the machinery without running the code generator.

Covers: queries (Find, Where, OrderBy, Limit, OR, Count, Exists, string Contains) AND transactions (insert, update with change tracking, delete, rollback, mid-tx SaveChanges).

It shows both transaction forms. Engine.WithTx puts the transaction in the context, which is what generated code does through db.WithTx and db.Tx(ctx). Engine.Transaction passes the transaction by hand.

Usage:

export DATABASE_URL="postgres://localhost:5432/drelexample?sslmode=disable"
go run ./examples/internals/

Jump to

Keyboard shortcuts

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