Session API reference¶
Construction¶
A session contains model collections, database transaction capability, runtime policies, and a private identity token.
Transaction¶
The callback session is bound to the underlying pgx.Tx and has a distinct session identity. Returning nil commits. Returning an error rolls back and returns that error. Panicking rolls back before the panic continues.
Options¶
Lazy-loading modes¶
type LazyLoadingMode uint8
const (
LazyLoadingAllowed LazyLoadingMode = iota
LazyLoadingLogged
LazyLoadingPrevented
)
The mode applies only when a relation query would be executed. Reading a populated cache remains permitted.
Identity contract¶
Models created or hydrated by a session retain that session. Association operations require matching identities. The framework does not silently reattach models.
Concurrency¶
Session and collection concurrency depends on the underlying database implementation and immutable runtime options. Model instances themselves are mutable and not concurrency-safe.