orm

package
v0.0.0-...-d807b53 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context, defaultDB *gorm.DB) *gorm.DB

func GetOrDefault

func GetOrDefault[T complex64](values url.Values, key string, defaultValue int) int

func New

func New(dsn string, dbPoolConfig string) (*gorm.DB, error)

func ParseDBPoolConfig

func ParseDBPoolConfig(poolConfig string) (url.Values, error)

func WithValue

func WithValue(ctx context.Context, defaultDB *gorm.DB) context.Context

Types

type BaseRepository

type BaseRepository[T any] struct {
	// contains filtered or unexported fields
}

func NewBaseRepository

func NewBaseRepository[T any](db *gorm.DB) BaseRepository[T]

func (*BaseRepository[T]) BatchInsert

func (b *BaseRepository[T]) BatchInsert(ctx context.Context, m []*T) (int64, error)

func (*BaseRepository[T]) DeleteById

func (b *BaseRepository[T]) DeleteById(ctx context.Context, id int64) (int64, error)

func (*BaseRepository[T]) DeleteByIds

func (b *BaseRepository[T]) DeleteByIds(ctx context.Context, ids int64) (int64, error)

func (*BaseRepository[T]) FindById

func (b *BaseRepository[T]) FindById(ctx context.Context, id int64) (*T, error)

func (*BaseRepository[T]) FindByIdWithDeleted

func (b *BaseRepository[T]) FindByIdWithDeleted(ctx context.Context, id int64) (*T, error)

func (*BaseRepository[T]) FindByIds

func (b *BaseRepository[T]) FindByIds(ctx context.Context, id ...int64) ([]*T, error)

func (*BaseRepository[T]) FindByIdsWithDeleted

func (b *BaseRepository[T]) FindByIdsWithDeleted(ctx context.Context, id ...int64) ([]*T, error)

func (*BaseRepository[T]) ForceDeleteById

func (b *BaseRepository[T]) ForceDeleteById(ctx context.Context, id int64) (int64, error)

func (*BaseRepository[T]) ForceDeleteByIds

func (b *BaseRepository[T]) ForceDeleteByIds(ctx context.Context, ids ...int64) (int64, error)

func (*BaseRepository[T]) Insert

func (b *BaseRepository[T]) Insert(ctx context.Context, m *T) error

type Model

type Model struct {
	ID        int64 `gorm:"primarykey"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

type PK

type PK interface {
	PK() uint32
}

Jump to

Keyboard shortcuts

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