Documentation
¶
Index ¶
- Variables
- func CheckIdentifier(name string) error
- func CheckRowsAffected(result interface{ ... }) error
- func ColumnName(fieldName string) string
- func IsCheckViolation(err error) bool
- func IsForeignKeyViolation(err error) bool
- func IsNotNullViolation(err error) bool
- func IsUniqueViolation(err error) bool
- func PivotColumnFor(structName string) string
- func TableNameFor(structName string) string
- type AfterCreateHook
- type AfterDeleteHook
- type AfterUpdateHook
- type BeforeCreateHook
- type BeforeDeleteHook
- type BeforeUpdateHook
- type ConstraintError
- type ConstraintKind
- type DB
- func (db *DB) Begin(ctx context.Context) (*Tx, error)
- func (db *DB) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
- func (db *DB) Close() error
- func (db *DB) Dialect() Dialect
- func (db *DB) Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (db *DB) Logger() Logger
- func (db *DB) Model[T any]() *Query[T]
- func (db *DB) Raw[T any](query string, args ...any) *RawQuery[T]
- func (db *DB) Relation[Parent, Child any](parent *Parent, name string) *RelationHandle[Parent, Child]
- func (db *DB) SQLDB() *sql.DB
- func (db *DB) Transaction(ctx context.Context, fn func(*Tx) error) error
- type Dialect
- type Field
- func (f Field[Model, Value]) Asc() Ordering
- func (f Field[Model, Value]) Between(low, high Value) Predicate
- func (f Field[Model, Value]) Column() string
- func (f Field[Model, Value]) Desc() Ordering
- func (f Field[Model, Value]) Eq(value Value) Predicate
- func (f Field[Model, Value]) Gt(value Value) Predicate
- func (f Field[Model, Value]) Gte(value Value) Predicate
- func (f Field[Model, Value]) In(values ...Value) Predicate
- func (f Field[Model, Value]) IsNotNull() Predicate
- func (f Field[Model, Value]) IsNull() Predicate
- func (f Field[Model, Value]) Lt(value Value) Predicate
- func (f Field[Model, Value]) Lte(value Value) Predicate
- func (f Field[Model, Value]) Ne(value Value) Predicate
- func (f Field[Model, Value]) NotIn(values ...Value) Predicate
- type FieldInfo
- type Logger
- type MappingError
- type ModelInfo
- type Numeric
- type Operation
- type Option
- type Ordering
- type Page
- type Predicate
- func And(predicates ...Predicate) Predicate
- func Between(column string, low, high any) Predicate
- func Eq(column string, value any) Predicate
- func Gt(column string, value any) Predicate
- func Gte(column string, value any) Predicate
- func In(column string, values ...any) Predicate
- func IsNotNull(column string) Predicate
- func IsNull(column string) Predicate
- func Like(column string, pattern string) Predicate
- func Lt(column string, value any) Predicate
- func Lte(column string, value any) Predicate
- func Ne(column string, value any) Predicate
- func Not(predicate Predicate) Predicate
- func NotIn(column string, values ...any) Predicate
- func NotLike(column string, pattern string) Predicate
- func Or(predicates ...Predicate) Predicate
- func RawPredicate(sql string, args ...any) Predicate
- type Query
- func (q *Query[T]) All(ctx context.Context) ([]T, error)
- func (q *Query[T]) As[R any]() *Query[R]
- func (q *Query[T]) Avg[V Numeric](ctx context.Context, column string) (V, error)
- func (q *Query[T]) Count(ctx context.Context) (int64, error)
- func (q *Query[T]) Create(ctx context.Context, entity *T) (sql.Result, error)
- func (q *Query[T]) CreateBatch(ctx context.Context, entities []*T) (sql.Result, error)
- func (q *Query[T]) Delete(ctx context.Context, entity *T) (sql.Result, error)
- func (q *Query[T]) DeleteAll(ctx context.Context) (sql.Result, error)
- func (q *Query[T]) DeleteSQL(entity *T) (string, []any, error)
- func (q *Query[T]) Distinct() *Query[T]
- func (q *Query[T]) Exists(ctx context.Context) (bool, error)
- func (q *Query[T]) Find(ctx context.Context, keys ...any) (*T, error)
- func (q *Query[T]) First(ctx context.Context) (*T, error)
- func (q *Query[T]) ForceDelete(ctx context.Context, entity *T) (sql.Result, error)
- func (q *Query[T]) ForceDeleteAll(ctx context.Context) (sql.Result, error)
- func (q *Query[T]) GroupBy(columns ...string) *Query[T]
- func (q *Query[T]) Having(predicates ...Predicate) *Query[T]
- func (q *Query[T]) InsertIgnore(ctx context.Context, entity *T, conflict ...string) (sql.Result, error)
- func (q *Query[T]) InsertSQL(entity *T) (string, []any, error)
- func (q *Query[T]) Join[U any](on Predicate) *Query[T]
- func (q *Query[T]) JoinTable(table string, on Predicate) *Query[T]
- func (q *Query[T]) LeftJoin[U any](on Predicate) *Query[T]
- func (q *Query[T]) LeftJoinTable(table string, on Predicate) *Query[T]
- func (q *Query[T]) Limit(limit int) *Query[T]
- func (q *Query[T]) Max[V any](ctx context.Context, column string) (V, error)
- func (q *Query[T]) Min[V any](ctx context.Context, column string) (V, error)
- func (q *Query[T]) Offset(offset int) *Query[T]
- func (q *Query[T]) OnlyTrashed() *Query[T]
- func (q *Query[T]) OrderBy(orderings ...Ordering) *Query[T]
- func (q *Query[T]) Paginate(ctx context.Context, page, perPage int) (*Page[T], error)
- func (q *Query[T]) Pluck[V any](ctx context.Context, column string) ([]V, error)
- func (q *Query[T]) Restore(ctx context.Context, entity *T) (sql.Result, error)
- func (q *Query[T]) SQL() (string, []any)
- func (q *Query[T]) Scope(scopes ...Scope[T]) *Query[T]
- func (q *Query[T]) Select(columns ...string) *Query[T]
- func (q *Query[T]) Sum[V Numeric](ctx context.Context, column string) (V, error)
- func (q *Query[T]) Table(name string) *Query[T]
- func (q *Query[T]) Update(ctx context.Context, entity *T) (sql.Result, error)
- func (q *Query[T]) UpdateAll(ctx context.Context, values map[string]any) (sql.Result, error)
- func (q *Query[T]) UpdateSQL(entity *T, columns ...string) (string, []any, error)
- func (q *Query[T]) Upsert(ctx context.Context, entity *T, conflict []string, update ...string) (sql.Result, error)
- func (q *Query[T]) Where(predicates ...Predicate) *Query[T]
- func (q *Query[T]) With(paths ...string) *Query[T]
- func (q *Query[T]) WithTrashed() *Query[T]
- type QueryEvent
- type RawQuery
- type RelationHandle
- func (h *RelationHandle[Parent, Child]) Add(ctx context.Context, children ...*Child) error
- func (h *RelationHandle[Parent, Child]) Attach(ctx context.Context, children ...*Child) error
- func (h *RelationHandle[Parent, Child]) AttachKeys(ctx context.Context, keys ...any) error
- func (h *RelationHandle[Parent, Child]) Count(ctx context.Context) (int64, error)
- func (h *RelationHandle[Parent, Child]) Detach(ctx context.Context, children ...*Child) error
- func (h *RelationHandle[Parent, Child]) DetachKeys(ctx context.Context, keys ...any) error
- func (h *RelationHandle[Parent, Child]) Load(ctx context.Context) error
- func (h *RelationHandle[Parent, Child]) Query() *Query[Child]
- func (h *RelationHandle[Parent, Child]) Remove(ctx context.Context, children ...*Child) error
- func (h *RelationHandle[Parent, Child]) Sync(ctx context.Context, children ...*Child) error
- func (h *RelationHandle[Parent, Child]) SyncKeys(ctx context.Context, keys ...any) error
- func (h *RelationHandle[Parent, Child]) Toggle(ctx context.Context, children ...*Child) error
- func (h *RelationHandle[Parent, Child]) ToggleKeys(ctx context.Context, keys ...any) error
- type RelationInfo
- type RelationKind
- type Scope
- type TableNamer
- type TagInfo
- type Tx
- func (tx *Tx) AfterCommit(callback func(context.Context) error) error
- func (tx *Tx) Commit() error
- func (tx *Tx) CommitContext(ctx context.Context) error
- func (tx *Tx) Dialect() Dialect
- func (tx *Tx) Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (tx *Tx) Model[T any]() *Query[T]
- func (tx *Tx) Raw[T any](query string, args ...any) *RawQuery[T]
- func (tx *Tx) Relation[Parent, Child any](parent *Parent, name string) *RelationHandle[Parent, Child]
- func (tx *Tx) ReleaseSavepoint(ctx context.Context, name string) error
- func (tx *Tx) Rollback() error
- func (tx *Tx) RollbackTo(ctx context.Context, name string) error
- func (tx *Tx) Savepoint(ctx context.Context, name string) error
- type UnsupportedFeatureError
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("orm: record not found") ErrClosed = errors.New("orm: transaction is closed") ErrUnsafeMutation = errors.New("orm: update or delete requires a predicate") ErrUnsupported = errors.New("orm: unsupported feature") ErrNoRowsAffected = errors.New("orm: no rows affected") ErrConstraint = errors.New("orm: constraint violated") )
var ErrInvalidIdentifier = errors.New("orm: invalid identifier")
ErrInvalidIdentifier reports a name that cannot be safely interpolated into SQL.
Functions ¶
func CheckIdentifier ¶
CheckIdentifier rejects anything that is not a plain SQL identifier.
Some names — savepoints above all — cannot be passed as bound parameters and must be written into the statement text, so they are validated rather than trusted.
func CheckRowsAffected ¶
func ColumnName ¶
ColumnName returns the column a struct field maps to by default.
func IsCheckViolation ¶
func IsForeignKeyViolation ¶
func IsNotNullViolation ¶
func IsUniqueViolation ¶
These report the constraint class of an error produced anywhere in the ORM. They are named "...Violation" to stay clear of the predicate constructors in expr.go, where IsNull and IsNotNull build SQL rather than inspect errors.
func PivotColumnFor ¶
PivotColumnFor returns the conventional pivot column for a model name.
func TableNameFor ¶
TableNameFor returns the table a model type name maps to by default. It does not consult TableNamer, which only a concrete type can answer.
Types ¶
type AfterCreateHook ¶
type AfterDeleteHook ¶
type AfterUpdateHook ¶
type BeforeCreateHook ¶
type BeforeDeleteHook ¶
type BeforeUpdateHook ¶
type ConstraintError ¶
type ConstraintError struct {
Kind ConstraintKind
Constraint string
Table string
Columns []string
Cause error
}
ConstraintError is the normalised form of a driver constraint violation. Dialect.ClassifyError builds it; the fields it can fill vary by driver.
func (*ConstraintError) Error ¶
func (e *ConstraintError) Error() string
func (*ConstraintError) Is ¶
func (e *ConstraintError) Is(target error) bool
func (*ConstraintError) Unwrap ¶
func (e *ConstraintError) Unwrap() error
type ConstraintKind ¶
type ConstraintKind int
ConstraintKind classifies a constraint violation reported by the driver.
const ( ConstraintUnknown ConstraintKind = iota ConstraintUnique ConstraintForeignKey ConstraintNotNull ConstraintCheck )
func (ConstraintKind) String ¶
func (k ConstraintKind) String() string
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) Begin ¶
Begin starts a transaction the caller is responsible for finishing.
Transaction is the safer choice and should be preferred: it commits, rolls back and handles panics for you. Begin exists for callers that must hand the handle around, such as an adapter implementing an external contract.
func (*DB) Model ¶
Model starts a typed query. Raw starts a typed hand-written query.
These are generic methods, which Go 1.27 permits on concrete types. That is why DB and Tx are concrete and why there is no shared interface over them: a method with its own type parameters can never satisfy an interface, so a Querier abstraction carrying Model[T] would not compile.
type Dialect ¶
type Dialect interface {
Name() string
Quote(string) string
Placeholder(int) string
// SupportsReturning reports whether INSERT ... RETURNING is available.
// Where it is not, generated keys come from LastInsertId instead.
SupportsReturning() bool
// ClassifyError maps a driver error onto a normalised ORM error such as
// *ConstraintError. It returns the original error when unrecognised.
ClassifyError(error) error
// UpsertClause renders the suffix that turns an INSERT into an upsert.
// conflict names the columns that identify an existing row; update names
// the columns to overwrite, and being empty means "leave the row alone".
UpsertClause(conflict, update []string) (string, error)
}
Dialect controls SQL syntax and error semantics that differ between supported databases.
Dialect is an interface, so it must never gain methods with their own type parameters: Go 1.27 generic methods exist on concrete types only and cannot participate in interface satisfaction.
type Field ¶
type Field[Model, Value any] struct { // contains filtered or unexported fields }
Field is a model field descriptor. The Value type parameter prevents comparing, say, a bool column against a string. Descriptors are ordinary Go values: hand-write them now, generate them later.
type Logger ¶
type Logger func(context.Context, QueryEvent)
Logger receives every statement the ORM executes, including the extra queries eager loading issues.
It is called synchronously on the query path, so a slow logger slows every query. Hand off to a channel or a buffered writer if the work is expensive.
type MappingError ¶
MappingError reports a column that could not be mapped onto a model field.
func (*MappingError) Error ¶
func (e *MappingError) Error() string
func (*MappingError) Unwrap ¶
func (e *MappingError) Unwrap() error
type ModelInfo ¶
type ModelInfo struct {
Type reflect.Type
Table string
Fields []FieldInfo
ByColumn map[string]FieldInfo
ByName map[string]FieldInfo
// PrimaryKeys holds every primary-key column in declaration order.
// PrimaryKey is the single key, or nil when the model has none or a
// composite one.
PrimaryKeys []FieldInfo
PrimaryKey *FieldInfo
Relations []RelationInfo
ByRelation map[string]RelationInfo
// Lifecycle columns, detected by tag or by conventional name. Nil when
// the model does not declare one.
SoftDelete *FieldInfo
CreatedAt *FieldInfo
UpdatedAt *FieldInfo
}
func ModelInfoFor ¶
func (*ModelInfo) HasCompositeKey ¶
HasCompositeKey reports whether the model is keyed on more than one column.
func (*ModelInfo) HasSoftDelete ¶
HasSoftDelete reports whether reads should hide soft-deleted rows.
type Numeric ¶
type Numeric interface {
~int | ~int8 | ~int16 | ~int32 | ~int64 |
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 |
~float32 | ~float64
}
Numeric constrains the aggregate helpers that only make sense over numbers.
type Operation ¶
type Operation string
Operation distinguishes the two kinds of statement the ORM issues.
type Option ¶
type Option func(*DB)
func WithDialect ¶
func WithSlogLogger ¶
WithSlogLogger logs statements through log/slog, at debug level for successes and error level for failures.
type Ordering ¶
type Ordering struct {
// contains filtered or unexported fields
}
Ordering is one ORDER BY term.
func RawOrdering ¶
RawOrdering embeds literal ORDER BY SQL, for expressions the builder cannot express (COALESCE, CASE, NULLS LAST).
type Page ¶
Page is one page of results plus the totals needed to render a pager.
type Predicate ¶
type Predicate struct {
// contains filtered or unexported fields
}
Predicate is the single currency of the query DSL. String constructors (orm.Eq) and generated field descriptors (UserFields.Active.Eq) both build one, so there is exactly one Where signature and one SQL compiler.
Predicates stay structured until compile time because quoting and placeholder numbering both depend on the dialect, which is not known when the predicate is constructed.
func Eq ¶
String-based constructors. These take a column name and are the path the GPA adapter uses, since GPA delivers column names as runtime strings.
func RawPredicate ¶
RawPredicate embeds literal SQL. Placeholders are written as ? and are renumbered per dialect; identifiers are passed through untouched.
type Query ¶
type Query[T any] struct { // contains filtered or unexported fields }
Query is an immutable, chainable query over T. Every builder method returns a copy, so a partially built query can be shared and branched safely.
func (*Query[T]) As ¶
As reprojects the query into a different result type while keeping the source table, predicates, joins and ordering. This is what makes joins and report DTOs usable without dropping to raw SQL: Query[T] would otherwise be permanently locked to returning []T.
func (*Query[T]) Count ¶
Count reports how many rows match. quoteColumn leaves "*" alone, so this renders as COUNT(*).
func (*Query[T]) CreateBatch ¶
CreateBatch inserts many entities in a single multi-row statement.
func (*Query[T]) Delete ¶
Delete removes the entity. When the model declares a soft-delete column the row is marked rather than removed; ForceDelete always removes it.
func (*Query[T]) DeleteAll ¶
DeleteAll removes every matching row. Like UpdateAll it refuses to run without a predicate.
func (*Query[T]) Find ¶
Find looks a row up by primary key. A composite key takes one value per column, in declaration order.
func (*Query[T]) ForceDelete ¶
ForceDelete issues a real DELETE even for a soft-deletable model.
func (*Query[T]) ForceDeleteAll ¶
ForceDeleteAll removes matching rows outright, even for a soft-deletable model. It carries the same predicate requirement as DeleteAll.
func (*Query[T]) InsertIgnore ¶
func (q *Query[T]) InsertIgnore(ctx context.Context, entity *T, conflict ...string) (sql.Result, error)
InsertIgnore inserts the entity, doing nothing if it already exists.
func (*Query[T]) Join ¶
Join adds an INNER JOIN against the table of U. LeftJoin adds a LEFT JOIN. The type parameter supplies the joined table name, so the join stays in sync with the model rather than a hand-written string.
func (*Query[T]) JoinTable ¶
JoinTable and LeftJoinTable join a table by name, for the cases where the joined side has no model to infer it from — a lookup table, or a caller such as the GPA adapter that receives the table as a runtime string.
func (*Query[T]) LeftJoinTable ¶
func (*Query[T]) OnlyTrashed ¶
func (*Query[T]) Paginate ¶
Paginate returns one page of results together with the total row count. Pages are 1-based.
func (*Query[T]) Scope ¶
Scope applies reusable query modifiers, so common filters can be named once and composed.
func (*Query[T]) UpdateAll ¶
UpdateAll applies a column/value map to every matching row.
A predicate is mandatory: an unfiltered UPDATE is almost always a mistake, and ErrUnsafeMutation makes it an explicit opt-in rather than a silent table rewrite.
func (*Query[T]) Upsert ¶
func (q *Query[T]) Upsert(ctx context.Context, entity *T, conflict []string, update ...string) (sql.Result, error)
Upsert inserts the entity, or updates the named columns when a row with the same conflict columns already exists.
With no update columns, every mapped column except the conflict columns and the auto-increment key is overwritten. Use InsertIgnore to insert only.
A generated key is not written back: the statement may update an existing row rather than insert, so there is no new key to report.
func (*Query[T]) With ¶
With eager-loads relations, including nested paths such as "Posts.Comments".
func (*Query[T]) WithTrashed ¶
WithTrashed includes soft-deleted rows. OnlyTrashed returns just those.
type QueryEvent ¶
type QueryEvent struct {
Operation Operation
SQL string
Args []any
Duration time.Duration
Err error
// Rows is the number of rows affected by an exec, or -1 when the figure
// is unavailable — which it always is for a query, since rows are counted
// as they are scanned, long after the statement returns.
Rows int64
}
QueryEvent describes one executed statement.
func (QueryEvent) String ¶
func (e QueryEvent) String() string
String renders the event as a single readable line.
type RawQuery ¶
type RawQuery[T any] struct { // contains filtered or unexported fields }
RawQuery is a typed handle over hand-written SQL.
type RelationHandle ¶
type RelationHandle[Parent, Child any] struct { // contains filtered or unexported fields }
RelationHandle operates on one association of one parent record.
The receiver is the database handle rather than the model, so models stay plain structs: a struct that carries a live connection cannot be safely serialised, copied between goroutines, or built in a test without a database.
func (*RelationHandle[Parent, Child]) Add ¶
func (h *RelationHandle[Parent, Child]) Add(ctx context.Context, children ...*Child) error
Add associates children with the parent, inserting them when they are new and updating the foreign key when they already exist.
func (*RelationHandle[Parent, Child]) Attach ¶
func (h *RelationHandle[Parent, Child]) Attach(ctx context.Context, children ...*Child) error
Attach links children to the parent. It is idempotent: keys already present in the pivot are skipped rather than duplicated.
func (*RelationHandle[Parent, Child]) AttachKeys ¶
func (h *RelationHandle[Parent, Child]) AttachKeys(ctx context.Context, keys ...any) error
AttachKeys, DetachKeys, SyncKeys and ToggleKeys are the key-based forms, for when the related rows are known by identifier rather than loaded.
func (*RelationHandle[Parent, Child]) Count ¶
func (h *RelationHandle[Parent, Child]) Count(ctx context.Context) (int64, error)
func (*RelationHandle[Parent, Child]) Detach ¶
func (h *RelationHandle[Parent, Child]) Detach(ctx context.Context, children ...*Child) error
Detach unlinks children. Calling it with none detaches everything.
func (*RelationHandle[Parent, Child]) DetachKeys ¶
func (h *RelationHandle[Parent, Child]) DetachKeys(ctx context.Context, keys ...any) error
func (*RelationHandle[Parent, Child]) Load ¶
func (h *RelationHandle[Parent, Child]) Load(ctx context.Context) error
Load fetches the association and assigns it onto the parent.
func (*RelationHandle[Parent, Child]) Query ¶
func (h *RelationHandle[Parent, Child]) Query() *Query[Child]
Query returns a query over the related rows, ready for further filtering.
func (*RelationHandle[Parent, Child]) Remove ¶
func (h *RelationHandle[Parent, Child]) Remove(ctx context.Context, children ...*Child) error
Remove dissociates children by clearing the foreign key. It never deletes rows: dropping a record is a separate, explicit decision.
func (*RelationHandle[Parent, Child]) Sync ¶
func (h *RelationHandle[Parent, Child]) Sync(ctx context.Context, children ...*Child) error
Sync makes the association exactly the given set, attaching what is missing and detaching what is no longer wanted.
func (*RelationHandle[Parent, Child]) SyncKeys ¶
func (h *RelationHandle[Parent, Child]) SyncKeys(ctx context.Context, keys ...any) error
func (*RelationHandle[Parent, Child]) Toggle ¶
func (h *RelationHandle[Parent, Child]) Toggle(ctx context.Context, children ...*Child) error
Toggle attaches keys that are absent and detaches those already present.
func (*RelationHandle[Parent, Child]) ToggleKeys ¶
func (h *RelationHandle[Parent, Child]) ToggleKeys(ctx context.Context, keys ...any) error
type RelationInfo ¶
type RelationInfo struct {
Name string
Kind RelationKind
Target reflect.Type
Index []int
// ForeignKeyField names the struct field holding the foreign key. For
// HasOne and HasMany it lives on Target; for BelongsTo it lives on the
// declaring model.
ForeignKeyField string
// ReferencesField names the key field on the opposite side. Empty means
// the primary key.
ReferencesField string
// Pivot describes the join table for ManyToMany. Populated at parse time
// so the shape stays stable once many-to-many lands, but not yet used.
PivotTable string
PivotForeignKey string
PivotTargetKey string
}
RelationInfo describes one association declared on a model.
Target metadata is resolved lazily, never during collectFields: two models that reference each other (User.Posts and Post.User) would otherwise recurse forever through modelInfoFor.
type RelationKind ¶
type RelationKind int
RelationKind enumerates the relationship shapes the mapper understands.
const ( RelationNone RelationKind = iota HasOne HasMany BelongsTo ManyToMany )
func (RelationKind) String ¶
func (k RelationKind) String() string
type TableNamer ¶
type TableNamer interface{ TableName() string }
TableNamer lets a model override the inflected table name.
type TagInfo ¶
type TagInfo struct {
Column string
PrimaryKey bool
AutoIncrement bool
Skip bool
SoftDelete bool
AutoCreateTime bool
AutoUpdateTime bool
Relation RelationKind
RelationKey string
References string
PivotTable string
PivotForeignKey string
PivotTargetKey string
}
TagInfo is the parsed form of an orm struct tag.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
func (*Tx) AfterCommit ¶
AfterCommit registers a callback that runs only once the database commit has succeeded. It cannot roll the transaction back.
func (*Tx) Model ¶
Model and Raw mirror the DB methods so a transaction is a drop-in replacement for the connection in any unit of work.
func (*Tx) Relation ¶
func (tx *Tx) Relation[Parent, Child any](parent *Parent, name string) *RelationHandle[Parent, Child]
Relation mirrors DB.Relation inside a transaction.
func (*Tx) ReleaseSavepoint ¶
ReleaseSavepoint discards a savepoint, keeping the work done since it.
func (*Tx) RollbackTo ¶
RollbackTo undoes everything done since the named savepoint.
type UnsupportedFeatureError ¶
func (*UnsupportedFeatureError) Error ¶
func (e *UnsupportedFeatureError) Error() string
func (*UnsupportedFeatureError) Is ¶
func (e *UnsupportedFeatureError) Is(target error) bool
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
ormgen
command
Command ormgen generates typed field descriptors for Lemmego ORM models.
|
Command ormgen generates typed field descriptors for Lemmego ORM models. |
|
internal
|
|
|
genfixture
Package genfixture holds models used to exercise the ormgen generator.
|
Package genfixture holds models used to exercise the ormgen generator. |
|
Package ormgen generates typed field descriptors for ORM models.
|
Package ormgen generates typed field descriptors for ORM models. |