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/
Click to show internal directories.
Click to hide internal directories.