gorm

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTransactionFunc

func NewTransactionFunc(db *gorm.DB) sqldb.TransactionFunc

NewTransactionFunc returns a TransactionFunc.

func TransactionFrom

func TransactionFrom(ctx context.Context) *gorm.DB

func WithTransaction

func WithTransaction(ctx context.Context, tx *gorm.DB) context.Context

Types

type Model

type Model[T any] struct {
	sqldb.ColumnHint[T]
	// contains filtered or unexported fields
}

Model implements the sqldb.Model interface.

func NewModel

func NewModel[T any](db *gorm.DB) Model[T]

NewModel returns a new Model.

func (Model[T]) Create

func (m Model[T]) Create(ctx context.Context, entity *T) error

func (Model[T]) Delete

func (m Model[T]) Delete(ctx context.Context, opts sqldb.FilterOptions) error

func (Model[T]) Get

func (m Model[T]) Get(ctx context.Context, opts []sqldb.OpQueryOptionInterface) (entity *T, err error)

func (Model[T]) List

func (m Model[T]) List(ctx context.Context, opts sqldb.ListOptions) (entities []*T, total uint64, err error)

func (Model[T]) Update

func (m Model[T]) Update(ctx context.Context, query sqldb.FilterOptions, opts []sqldb.UpdateOptionInterface) (uint64, error)

Jump to

Keyboard shortcuts

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