gorm

package module
v0.0.0-...-809c06e Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: MIT Imports: 5 Imported by: 0

README

generic-gorm

gorm package with generic types

Usage

go get github.com/STRockefeller/generic-gorm

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NoWait

func NoWait() forUpdateOption

Types

type DB

type DB[M any] struct {
	// contains filtered or unexported fields
}

where M is a gorm model

func NewDB

func NewDB[M any](db *gorm.DB) DB[M]

func NewDBWithTimeout

func NewDBWithTimeout[M any](db *gorm.DB, timeOut time.Duration) DB[M]

func (DB[M]) Begin

func (container DB[M]) Begin(opts ...*sql.TxOptions) DB[M]

func (DB[M]) Commit

func (container DB[M]) Commit() error

func (DB[M]) Count

func (container DB[M]) Count(ctx context.Context) (result int64, err error)

func (DB[M]) Create

func (container DB[M]) Create(ctx context.Context, instances []M) error

func (DB[M]) Delete

func (container DB[M]) Delete(ctx context.Context, condition M) (rawsAffected int64, err error)

func (DB[M]) Error

func (container DB[M]) Error() error

func (DB[M]) Find

func (container DB[M]) Find(ctx context.Context) (result []M, err error)

func (DB[M]) FindForUpdate

func (container DB[M]) FindForUpdate(ctx context.Context, opts ...forUpdateOption) (result []M, err error)

func (DB[M]) ForUpdate

func (container DB[M]) ForUpdate(opts ...forUpdateOption) DB[M]

func (DB[M]) Joins

func (container DB[M]) Joins(query string, args ...interface{}) DB[M]

func (DB[M]) Limit

func (container DB[M]) Limit(limit int) DB[M]

func (DB[M]) Offset

func (container DB[M]) Offset(offset int) DB[M]

func (DB[M]) OrderBy

func (container DB[M]) OrderBy(columnName string, order Order) DB[M]

func (DB[M]) OrderByAscending

func (container DB[M]) OrderByAscending(columnName string) DB[M]

func (DB[M]) OrderByDescending

func (container DB[M]) OrderByDescending(columnName string) DB[M]

func (DB[M]) RollBack

func (container DB[M]) RollBack() error

func (DB[M]) Scope

func (container DB[M]) Scope(f func(*gorm.DB) *gorm.DB) DB[M]

func (DB[M]) Take

func (container DB[M]) Take(ctx context.Context) (result M, err error)

func (DB[M]) TakeForUpdate

func (container DB[M]) TakeForUpdate(ctx context.Context, opts ...forUpdateOption) (result M, err error)

func (DB[M]) Updates

func (container DB[M]) Updates(ctx context.Context, instance M) (rowsAffected int64, err error)

func (DB[M]) Upsert

func (container DB[M]) Upsert(ctx context.Context, instances []M, clause clause.OnConflict) error

func (DB[M]) Where

func (container DB[M]) Where(condition M) DB[M]

func (DB[M]) WhereRaw

func (container DB[M]) WhereRaw(condition string, args ...interface{}) DB[M]

type Order

type Order bool
const (
	Desc Order = true
	Asc  Order = false
)

Jump to

Keyboard shortcuts

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