hades

package
v12.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromDBName

func FromDBName(dbname string) string

Types

type AllEntities

type AllEntities map[reflect.Type]EntityMap

type ChangedFields

type ChangedFields map[string]interface{}

func DiffRecord

func DiffRecord(x, y interface{}, scope *gorm.Scope) (ChangedFields, error)

type Context

type Context struct {
	Consumer *state.Consumer
	ScopeMap ScopeMap
	Stats    Stats
}

func NewContext

func NewContext(db *gorm.DB, models []interface{}, consumer *state.Consumer) *Context

func (*Context) InTransaction

func (c *Context) InTransaction(db *gorm.DB, itf InTransactionFunc) error

func (*Context) NewManyToMany

func (c *Context) NewManyToMany(JoinTable string, SourceForeignKeys, DestinationForeignKeys []gorm.JoinTableForeignKey) (*ManyToMany, error)

func (*Context) Preload

func (c *Context) Preload(db *gorm.DB, params *PreloadParams) error

func (*Context) Save

func (c *Context) Save(db *gorm.DB, params *SaveParams) error

func (*Context) SaveNoTransaction

func (c *Context) SaveNoTransaction(tx *gorm.DB, params *SaveParams) error

func (*Context) WalkType

func (c *Context) WalkType(riMap RecordInfoMap, name string, atyp reflect.Type, visited VisitMap, assocs []string) (*RecordInfo, error)

type DBCB

type DBCB func(db *gorm.DB) *gorm.DB

type EntityMap

type EntityMap []interface{}

type InTransactionFunc

type InTransactionFunc func(c *Context, tx *gorm.DB) error

type JoinRec

type JoinRec struct {
	DestinKey interface{}
	Record    reflect.Value
}

type ManyToMany

type ManyToMany struct {
	Scope *gorm.Scope

	JoinTable string

	SourceName        string
	SourceAssocName   string
	SourceDBName      string
	SourceAssocDBName string

	DestinName        string
	DestinAssocName   string
	DestinDBName      string
	DestinAssocDBName string

	// SourceKey => []JoinRec{DestinKey, Record}
	Values map[interface{}][]JoinRec
}

func (*ManyToMany) Add

func (mtm *ManyToMany) Add(Source reflect.Value, Destin reflect.Value)

func (*ManyToMany) AddKeys

func (mtm *ManyToMany) AddKeys(sourceKey interface{}, destinKey interface{}, record reflect.Value)

func (*ManyToMany) String

func (mtm *ManyToMany) String() string

type Node

type Node struct {
	Name     string
	Field    PreloadField
	Children map[string]*Node
}

func NewNode

func NewNode(name string) *Node

func (*Node) Add

func (n *Node) Add(pf PreloadField)

func (*Node) String

func (n *Node) String() string

type PreloadCB

type PreloadCB func(db *gorm.DB) *gorm.DB

type PreloadField

type PreloadField struct {
	Name    string
	OrderBy string
}

type PreloadParams

type PreloadParams struct {
	Record interface{}

	// Fields to preload, for example []string{"CollectionGames", "CollectionGames.Game"}
	Fields []PreloadField
}

type RecordInfo

type RecordInfo struct {
	Name         string
	Type         reflect.Type
	Children     []*RecordInfo
	Relationship *gorm.Relationship
	ManyToMany   *ManyToMany
	ModelStruct  *gorm.ModelStruct
}

func (*RecordInfo) String

func (ri *RecordInfo) String() string

type RecordInfoMap

type RecordInfoMap map[reflect.Type]*RecordInfo

type SaveParams

type SaveParams struct {
	// Record to save
	Record interface{}

	// Fields to save instead of the top-level record
	Assocs []string

	// Disable deleting join table entries (useful for partial data)
	PartialJoins []string
}

type ScopeMap

type ScopeMap map[reflect.Type]*gorm.Scope

func (ScopeMap) ByDBName

func (sm ScopeMap) ByDBName(dbName string) *gorm.Scope

type Stats

type Stats struct {
	Inserts int64
	Updates int64
	Deletes int64
	Current int64
}

type VisitMap

type VisitMap map[*gorm.ModelStruct]bool

func (VisitMap) CopyAndMark

func (vm VisitMap) CopyAndMark(ms *gorm.ModelStruct) VisitMap

Jump to

Keyboard shortcuts

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