dal

package
v0.0.0-...-f412a0c Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 16 Imported by: 1

Documentation

Overview

Package dal GENERATED BY gengo:runtimedoc DON'T EDIT THIS FILE

Index

Constants

This section is empty.

Variables

View Source
var ErrSkipScan = errors.New("scan skip")
View Source
var Scan = scanner.Scan

Functions

func ConfigureAdapter

func ConfigureAdapter(a adapter.Adapter, poolSize int, maxConnDur time.Duration)

func HardDelete

func HardDelete() func(m featureSettings)

func InSelect

func InSelect[T any](col sqlbuilder.TypedColumn[T], q Querier) sqlbuilder.ColumnValueExpr[T]

func IncludeAllRecord

func IncludeAllRecord() func(m featureSettings)

func InjectContext

func InjectContext(ctx context.Context, repo Session) context.Context

func NotInSelect

func NotInSelect[T any](col sqlbuilder.TypedColumn[T], q Querier) sqlbuilder.ColumnValueExpr[T]

func Tx

func Tx(ctx context.Context, m sqlbuilder.Model, action func(ctx context.Context) error) error

func WhereStmtNotEmpty

func WhereStmtNotEmpty() func(m featureSettings)

Types

type Database

type Database struct {
	// Endpoint of database
	Endpoint string `flag:""`
	// auto migrate before run
	EnableMigrate bool `flag:",omitempty"`
	// contains filtered or unexported fields
}

func (*Database) ApplyCatalog

func (d *Database) ApplyCatalog(name string, tables ...*sqlbuilder.Tables)

func (*Database) Init

func (d *Database) Init(ctx context.Context) error

func (*Database) InjectContext

func (d *Database) InjectContext(ctx context.Context) context.Context

func (*Database) Run

func (d *Database) Run(ctx context.Context) error

func (Database) RuntimeDoc

func (v Database) RuntimeDoc(names ...string) ([]string, bool)

func (*Database) SetDefaults

func (d *Database) SetDefaults()

type DeleteFunc

type DeleteFunc func()

func (DeleteFunc) RuntimeDoc

func (DeleteFunc) RuntimeDoc(names ...string) ([]string, bool)

type ModelWithAutoIncrement

type ModelWithAutoIncrement interface {
	SetAutoIncrementID(u int64)
}

type ModelWithCreationTime

type ModelWithCreationTime interface {
	MarkCreatedAt()
}

type ModelWithSoftDelete

type ModelWithSoftDelete interface {
	MarkDeletedAt()
	SoftDeleteFieldAndZeroValue() (string, driver.Value)
}

type ModelWithUpdationTime

type ModelWithUpdationTime interface {
	MarkUpdatedAt()
}

type Mutation

type Mutation[T any] interface {
	IncludesZero(zeroFields ...sqlbuilder.Column) Mutation[T]

	ForDelete(opts ...OptionFunc) Mutation[T]
	ForUpdateSet(assignments ...sqlbuilder.Assignment) Mutation[T]

	Where(where sqlbuilder.SqlExpr) Mutation[T]

	OnConflict(cols sqlbuilder.ColumnCollection) Mutation[T]
	DoNothing() Mutation[T]
	DoUpdateSet(cols ...sqlbuilder.Column) Mutation[T]
	DoWith(func(onConflictAddition sqlbuilder.OnConflictAddition) sqlbuilder.Addition) Mutation[T]

	Returning(cols ...sqlbuilder.SqlExpr) Mutation[T]
	Scan(recv any) Mutation[T]

	Save(ctx context.Context) error
}

func Prepare

func Prepare[T any](v *T) Mutation[T]

type OptionFunc

type OptionFunc func(m featureSettings)

func (OptionFunc) RuntimeDoc

func (OptionFunc) RuntimeDoc(names ...string) ([]string, bool)

type Querier

type Querier interface {
	sqlbuilder.SqlExpr

	ExistsTable(table sqlbuilder.Table) bool
	Apply(patchers ...QuerierPatcher) Querier

	With(t sqlbuilder.Table, build sqlbuilder.BuildSubQuery, modifiers ...string) Querier
	AsTemporaryTable(tableName string) TemporaryTable

	Join(t sqlbuilder.Table, on sqlbuilder.SqlExpr) Querier
	CrossJoin(t sqlbuilder.Table, on sqlbuilder.SqlExpr) Querier
	LeftJoin(t sqlbuilder.Table, on sqlbuilder.SqlExpr) Querier
	RightJoin(t sqlbuilder.Table, on sqlbuilder.SqlExpr) Querier
	FullJoin(t sqlbuilder.Table, on sqlbuilder.SqlExpr) Querier

	Where(where sqlbuilder.SqlExpr) Querier
	WhereAnd(where sqlbuilder.SqlExpr) Querier
	WhereOr(where sqlbuilder.SqlExpr) Querier

	OrderBy(orders ...*sqlbuilder.Order) Querier

	GroupBy(cols ...sqlbuilder.SqlExpr) Querier
	Having(where sqlbuilder.SqlExpr) Querier

	Limit(v int64) Querier
	Offset(v int64) Querier

	Distinct(extras ...sqlbuilder.SqlExpr) Querier
	Select(projects ...sqlbuilder.SqlExpr) Querier

	Scan(v any) Querier

	Find(ctx context.Context) error
	Count(ctx context.Context) (int, error)
}

func From

func From(from sqlbuilder.Table, fns ...OptionFunc) Querier

type QuerierPatcher

type QuerierPatcher interface {
	Apply(q Querier) Querier
}

type ScanIterator

type ScanIterator = scanner.ScanIterator

func Recv

func Recv[T any](next func(v *T) error) ScanIterator

type Session

type Session interface {
	// Name of database
	Name() string
	T(m any) sqlbuilder.Table
	Tx(ctx context.Context, fn func(ctx context.Context) error) error

	Adapter() adapter.Adapter
}

func FromContext

func FromContext(ctx context.Context, name string) Session

func New

func New(a adapter.Adapter, name string) Session

func SessionFor

func SessionFor(ctx context.Context, nameOrTable any) Session

type SoftDeleteValueGetter

type SoftDeleteValueGetter interface {
	GetDeletedAt() driver.Value
}

type TableWrapper

type TableWrapper interface {
	Unwrap() sqlbuilder.Model
}

type TemporaryTable

type TemporaryTable interface {
	sqlbuilder.Table
	TableWrapper
	QuerierPatcher
}

Jump to

Keyboard shortcuts

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