model-features

command
v0.9.0 Latest Latest
Warning

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

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

Documentation

Overview

Example: model-features

Demonstrates drel's built-in model traits: soft delete, optimistic concurrency (versioning), and audit columns. An Article model embeds all three traits and uses exported fields (Title, Body).

Key concepts shown:

  • SoftDelete: Remove sets deleted_at instead of deleting the row. Normal queries auto-filter deleted rows; Unscoped bypasses the filter. HardRemove permanently deletes the row.
  • Versioned: Each update increments a version column. Concurrent edits are detected via optimistic concurrency (WHERE version = N).
  • Audit: created_by/updated_by are populated from context via WithActor.

Usage:

cd examples/model-features
go run ../../cmd/drel generate   # generates articles/article_drel.go + db/drel_gen.go
export DATABASE_URL="postgres://localhost:5432/drelexample?sslmode=disable"
go run .

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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