entity

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: BSD-3-Clause Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const Tag = "db"

Variables

This section is empty.

Functions

func FieldByIndexes added in v1.5.0

func FieldByIndexes(v reflect.Value, indexes []int) reflect.Value

func FieldByIndexesRO added in v1.5.0

func FieldByIndexesRO(v reflect.Value, indexes []int) (reflect.Value, bool)

Types

type Columns

type Columns struct {
	Cols []string
	Vals []interface{}
}

func (*Columns) Len

func (s *Columns) Len() int

func (*Columns) Less

func (s *Columns) Less(i, j int) bool

func (*Columns) Swap

func (s *Columns) Swap(i, j int)

type FieldMapper

type FieldMapper struct {
	*reflectx.Mapper
}

func DefaultFieldMapper

func DefaultFieldMapper() *FieldMapper

func NewFieldMapper

func NewFieldMapper() *FieldMapper

func (*FieldMapper) Columns

func (m *FieldMapper) Columns(entity interface{}) (*Columns, *Columns)

func (*FieldMapper) ColumnsForType

func (m *FieldMapper) ColumnsForType(typ reflect.Type) []string

func (*FieldMapper) Keys

func (m *FieldMapper) Keys(entity interface{}) (*Values, error)

func (*FieldMapper) KeysForType

func (m *FieldMapper) KeysForType(typ reflect.Type) []string

func (*FieldMapper) TraversalsByName added in v1.1.0

func (m *FieldMapper) TraversalsByName(t reflect.Type, names []string) ([][]int, []bool)

TraversalsByName returns a slice of int slices which represent the struct traversals for each mapped name and a slice of bools which indicates whether each such traversal is omit-empty. Panics if t is not a struct or Indirectable to a struct. Returns empty int slice for each name not found.

func (*FieldMapper) TraversalsByNameFunc added in v1.1.0

func (m *FieldMapper) TraversalsByNameFunc(t reflect.Type, names []string, fn func(int, []int, bool) error) error

TraversalsByNameFunc traverses the mapped names and calls fn with the index of each name and the struct traversal represented by that name. Panics if t is not a struct or Indirectable to a struct. Returns the first error returned by fn or nil.

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

func NewGenerator

func NewGenerator(m *FieldMapper) *Generator

func (*Generator) Delete

func (g *Generator) Delete(table string, keys *Columns) (string, []interface{})

func (*Generator) Insert

func (g *Generator) Insert(table string, entity interface{}) (string, []interface{})

func (*Generator) Select

func (g *Generator) Select(table string, entity interface{}, keys *Columns) (string, []interface{})

func (*Generator) Update

func (g *Generator) Update(table string, entity interface{}, names []string) (string, []interface{})

func (*Generator) Upsert added in v1.9.6

func (g *Generator) Upsert(table string, entity interface{}, names []string) (string, []interface{})

type Synthetic added in v1.9.6

type Synthetic interface {
	AdditionalColumns() *Columns
}

Synthetic is implemented by entities that produce additional "synthetic" columns to be stored alongside columns derived from fields of the entity.

Synthetic columns are read-only, they will not be fetched back from the database. They are generally intended to be used in cases where derived values are computed from the state of an entity when it it stored, perhaps for indexing purposes.

type Values

type Values struct {
	Cols []string
	Vals []reflect.Value
}

type Zeroer added in v1.1.1

type Zeroer interface {
	IsZero() bool
}

implemented by values that can express their zeronoess/emptiness

Jump to

Keyboard shortcuts

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