Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ColumnMeta ¶
type ColumnMeta struct { ColumnName string FieldName string Typ reflect.Type IsPrimaryKey bool IsAutoIncrement bool // Offset 是字段偏移量。需要注意的是,这里的字段偏移量是相对于整个结构体的偏移量 // 例如在组合的情况下, // type A struct { // name string // B // } // type B struct { // age int // } // age 的偏移量是相对于 A 的起始地址的偏移量 Offset uintptr // IsHolderType 用于表达是否是 Holder 的类型 // 所谓的 Holder,就是指同时实现了 sql.Scanner 和 driver.Valuer 两个接口的类型 IsHolderType bool // FieldIndexes 用于表达从最外层结构体找到当前ColumnMeta对应的Field所需要的索引集 FieldIndexes []int }
ColumnMeta represents model's field, or column
type MetaRegistry ¶
type MetaRegistry interface { Get(table interface{}) (*TableMeta, error) Register(table interface{}, opts ...TableMetaOption) (*TableMeta, error) }
MetaRegistry stores table metadata
func NewMetaRegistry ¶
func NewMetaRegistry() MetaRegistry
func NewTagMetaRegistry ¶
func NewTagMetaRegistry() MetaRegistry
type TableMeta ¶
type TableMeta struct { TableName string Columns []*ColumnMeta // FieldMap 是字段名到列元数据的映射 FieldMap map[string]*ColumnMeta // ColumnMap 是列名到列元数据的映射 ColumnMap map[string]*ColumnMeta Typ reflect.Type }
TableMeta represents data model, or a table
type TableMetaOption ¶
type TableMetaOption func(meta *TableMeta)
TableMetaOption represents options of TableMeta, this options will cover default cover.
func IgnoreFieldsOption ¶
func IgnoreFieldsOption(fieldNames ...string) TableMetaOption
IgnoreFieldsOption function provide an option to ignore some fields when register table.
Click to show internal directories.
Click to hide internal directories.