db

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FetchOptBuilder

type FetchOptBuilder interface {
	WithDeletedAtIsNull(val ...bool) FetchOptBuilder
	EndQuery(query string) FetchOptBuilder
	FullQuery(query string) FetchOptBuilder
}

func FetchOpt

func FetchOpt() FetchOptBuilder

type Repo

type Repo[T any] interface {
	SetInsert(columns string, fn func(e *T) []any)

	Fetch(clog clog.Instance, condition string, args ...any) (*T, error)
	Fetches(clog clog.Instance, condition string, args ...any) ([]*T, error)
	Insert(clog clog.Instance, e *T) error
	InsertRID(clog clog.Instance, e *T) (*int64, error)
	Update(clog clog.Instance, builder UpdateBuilder) error
	Delete(clog clog.Instance, condition string, args ...any) error

	TxFetch(clog clog.Instance, tx ice.DbTx, condition string, args ...any) (*T, error)
	TxFetches(clog clog.Instance, tx ice.DbTx, condition string, args ...any) ([]*T, error)
	TxInsert(clog clog.Instance, tx ice.DbTx, e *T) error
	TxInsertRID(clog clog.Instance, tx ice.DbTx, e *T) (*int64, error)
	TxBulkInsert(clog clog.Instance, tx ice.DbTx, entities []*T, chunkSize ...int) error
	TxUpdate(clog clog.Instance, tx ice.DbTx, builder UpdateBuilder) error
	TxDelete(clog clog.Instance, tx ice.DbTx, condition string, args ...any) error
}

func NewRepo

func NewRepo[T any](db ice.DbInstance, tableName string, opt ...RepoOptBuilder) Repo[T]

type RepoOptBuilder

type RepoOptBuilder interface {
	WithDeletedAtIsNull(val ...bool) RepoOptBuilder
	RWFetchWhenNull(val ...bool) RepoOptBuilder
}

func RepoOpt

func RepoOpt() RepoOptBuilder

type UpdateBuilder

type UpdateBuilder interface {
	AutoUpdatedAt(val ...bool) UpdateBuilder
	Set(query string, args ...any) UpdateBuilder
	SetIfNotNil(keyVal map[string]any) UpdateBuilder
	Where(query string, args ...any) UpdateBuilder
}

func Update

func Update() UpdateBuilder

Jump to

Keyboard shortcuts

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