basic

command
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 8 Imported by: 0

README

Basic Example

This example introduces the ORM in a few minutes.

It shows:

  • Open()
  • Ping()
  • Close()
  • Create
  • Find
  • Update
  • Delete
  • explicit Raw SQL via WithoutPolicy()
  • a simple lifecycle hook
  • request-scoped context usage

Raw SQL uses generic ? placeholders and participates in the current transaction automatically:

err := db.Raw(ctx, `SELECT * FROM users WHERE email = ?`, email).
    WithoutPolicy().
    Scan(&users)

Run it with:

export DORM_EXAMPLE_DSN='host=localhost port=5432 dbname=dorm user=postgres password=postgres sslmode=disable'
go run ./examples/basic

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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