Documentation ¶
Index ¶
- Constants
- func FieldByIndexes(v reflect.Value, indexes []int) reflect.Value
- func FieldByIndexesRO(v reflect.Value, indexes []int) (reflect.Value, bool)
- type Columns
- type FieldMapper
- func (m *FieldMapper) Columns(entity interface{}) (*Columns, *Columns)
- func (m *FieldMapper) ColumnsForType(typ reflect.Type) []string
- func (m *FieldMapper) Keys(entity interface{}) (*Values, error)
- func (m *FieldMapper) KeysForType(typ reflect.Type) []string
- func (m *FieldMapper) TraversalsByName(t reflect.Type, names []string) ([][]int, []bool)
- func (m *FieldMapper) TraversalsByNameFunc(t reflect.Type, names []string, fn func(int, []int, bool) error) error
- type Generator
- func (g *Generator) Delete(table string, keys *Columns) (string, []interface{})
- func (g *Generator) Insert(table string, entity interface{}) (string, []interface{})
- func (g *Generator) Select(table string, entity interface{}, keys *Columns) (string, []interface{})
- func (g *Generator) Update(table string, entity interface{}, names []string) (string, []interface{})
- func (g *Generator) Upsert(table string, entity interface{}, names []string) (string, []interface{})
- type Synthetic
- type Values
- type Zeroer
Constants ¶
const Tag = "db"
Variables ¶
This section is empty.
Functions ¶
func FieldByIndexes ¶ added in v1.5.0
Types ¶
type FieldMapper ¶
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
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
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.