Help us shape the future of Go! Take the 2026 Go Developer Survey

model

package
v0.0.0-...-566fe3c Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Dialect = goqu.Dialect("postgres")

Functions

func CopyMigration

func CopyMigration(file string, pathToRoot string) error

func EmptyTransfer

func EmptyTransfer[Agr any, Dpd any, Nd Keyed, In any](aggregate Agr, _ Dpd, _ In) (Agr, Nd, error)

func GetIn

func GetIn(executer gorp.SqlExecutor, records interface{}, conditions map[string][]interface{}, forLock bool) ([]interface{}, error)

func GetMax

func GetMax(executer gorp.SqlExecutor, records interface{}, maxColName string, conditions map[string]interface{}) (int, error)

func GetPaging

func GetPaging(executer gorp.SqlExecutor, records interface{}, conditions map[string]interface{}, orders []Order, pager basic.Pager) ([]interface{}, error)

func Migrate

func Migrate(db *sql.DB, pathToRoot string) error

func Mutate

func Mutate[R any](executer gorp.SqlExecutor, dels []R, upds []R, inss []R) error

* 集約中のリスト構造をまとめてDBに反映させる

func Select

func Select[R any](executer gorp.SqlExecutor, query *goqu.SelectDataset) ([]R, error)

func SelectSingle

func SelectSingle[R any](executer gorp.SqlExecutor, table string, keys map[string]string, query string, args ...interface{}) (*R, error)

* gorpのSelectOneは、レコードが見つからない場合にエラーになっちゃうがnilで返したいのでSelectSingleを作成

Types

type DBAccess

type DBAccess struct {
	Name string `env:"DB_NAME,notEmpty"`
	Host string `env:"DB_HOST,notEmpty"`
	Port uint   `env:"DB_PORT,notEmpty"`
	User string `env:"DB_USER,notEmpty"`
	Pass string `env:"DB_PASSWORD,notEmpty"`
}

func NewDBAccess

func NewDBAccess(
	name string,
	host string,
	port uint,
	user string,
	pass string,
) DBAccess

func (DBAccess) CreateConnection

func (dbAccess DBAccess) CreateConnection() (*sql.DB, error)

type Executor

type Executor interface {
	gorp.SqlExecutor
	GetIn(records interface{}, conditions map[string][]interface{}, forLock bool) ([]interface{}, error)
	GetMax(records interface{}, maxColName string, conditions map[string]interface{}) (int, error)
	GetPaging(records interface{}, conditions map[string]interface{}, orders []Order, pager basic.Pager) ([]interface{}, error)
}

type GenerateNumber

type GenerateNumber[Dpd any] func(gorp.SqlExecutor, Dpd) (uint, error)

type Keyed

type Keyed interface {
	Keys() []interface{}
}

type MutationList

type MutationList[Nd any] struct {
	Dels []Nd
	Upds []Nd
	Inss []Nd
}

func EmptyReplace

func EmptyReplace[Agr any, Dpd any, Nd any, In any](aggregate Agr, _ Dpd, _ In) (Agr, MutationList[Nd], error)

func (MutationList[Nd]) Merge

func (ml MutationList[Nd]) Merge(additional MutationList[Nd]) MutationList[Nd]

type ORP

type ORP struct {
	gorp.SqlExecutor
	// contains filtered or unexported fields
}

dbMapはtransactionを開始した際に、退避するためのフィールドなので、transactionが開始されていない場合はnil。

func (*ORP) Begin

func (orp *ORP) Begin() error

func (*ORP) Close

func (orp *ORP) Close() error

func (*ORP) Commit

func (orp *ORP) Commit() error

func (*ORP) GetIn

func (o *ORP) GetIn(records interface{}, conditions map[string][]interface{}, forLock bool) ([]interface{}, error)

func (*ORP) GetMax

func (o *ORP) GetMax(records interface{}, maxColName string, conditions map[string]interface{}) (int, error)

func (*ORP) GetPaging

func (o *ORP) GetPaging(records interface{}, conditions map[string]interface{}, orders []Order, pager basic.Pager) ([]interface{}, error)

func (*ORP) InsideTransaction

func (orp *ORP) InsideTransaction() bool

func (*ORP) Rollback

func (orp *ORP) Rollback() error

type ORPer

type ORPer interface {
	TransactionalDatabase
	Executor
}

func CreateDatabase

func CreateDatabase(connection *sql.DB, registerTable func(*gorp.DbMap)) ORPer

type Order

type Order struct {
	Column    string
	Ascending bool
}

func NewOrder

func NewOrder(column string, ascending bool) Order

type Replace

type Replace[Agr any, Dpd any, Nd any, In any] func(Agr, Dpd, In) (Agr, MutationList[Nd], error)

type Transactional

type Transactional interface {
	Begin() error
	Commit() error
	Rollback() error
}

type TransactionalDatabase

type TransactionalDatabase interface {
	Transactional
	basic.Closable
}

type Transfer

type Transfer[Agr any, Dpd any, Nd Keyed, In any] func(Agr, Dpd, In) (Agr, Nd, error)

type TransferWithId

type TransferWithId[Agr any, Dpd any, Nd Keyed, In any] func(Agr, Dpd, In, basic.Identifier) (Agr, Nd, error)

type TransferWithIdAndNumber

type TransferWithIdAndNumber[Agr any, Dpd any, Nd Keyed, In any] func(Agr, Dpd, In, basic.Identifier, uint) (Agr, Nd, error)

type Transferable

type Transferable[Agr any, Dpd any, Nd Keyed] interface {
	Transfer(Agr, Dpd) (Agr, Nd, error)
}

type TransferableList

type TransferableList[Agr any, Dpd any, Nd any] interface {
	TransferList(Agr, Dpd) (Agr, MutationList[Nd], error)
}

type TransferableRootAndMulti

type TransferableRootAndMulti[Agr any, Dpd any, Rt Keyed, Sb any] interface {
	TransferRootAndMulti(Agr, Dpd, basic.Identifier, uint) (Agr, Rt, []Sb, error)
}

type TransferableRootAndSub

type TransferableRootAndSub[Agr any, Dpd any, Rt Keyed, Sb any] interface {
	TransferRootAndSub(Agr, Dpd, basic.Identifier, uint) (Agr, Rt, Sb, error)
}

type TransferableWithId

type TransferableWithId[Agr any, Dpd any, Nd Keyed] interface {
	TransferWithId(Agr, Dpd, basic.Identifier) (Agr, Nd, error)
}

type TransferableWithIdAndNumber

type TransferableWithIdAndNumber[Agr any, Dpd any, Nd Keyed] interface {
	TransferWithIdAndNumber(Agr, Dpd, basic.Identifier, uint) (Agr, Nd, error)
}

Jump to

Keyboard shortcuts

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