Documentation
      ¶
    
    
  
    
  
    Index ¶
- Variables
 - func GetIdentityFieldValuesMap(reflectValue reflect.Value, fields []*Field) (map[string][]reflect.Value, [][]interface{})
 - func GetIdentityFieldValuesMapFromValues(values []interface{}, fields []*Field) (map[string][]reflect.Value, [][]interface{})
 - func GetRelationsValues(reflectValue reflect.Value, rels []*Relationship) (reflectResults reflect.Value)
 - func ParseTagSetting(str string, sep string) map[string]string
 - func ToQueryValues(table string, foreignKeys []string, foreignValues [][]interface{}) (interface{}, []interface{})
 - type Check
 - type Constraint
 - type CreateClausesInterface
 - type DataType
 - type DataTypeInterface
 - type DeleteClausesInterface
 - type Field
 - type Index
 - type IndexOption
 - type Namer
 - type NamingStrategy
 - func (ns NamingStrategy) CheckerName(table, column string) string
 - func (ns NamingStrategy) ColumnName(table, column string) string
 - func (ns NamingStrategy) IndexName(table, column string) string
 - func (ns NamingStrategy) JoinTableName(str string) string
 - func (ns NamingStrategy) RelationshipFKName(rel Relationship) string
 - func (ns NamingStrategy) TableName(str string) string
 
- type Polymorphic
 - type QueryClausesInterface
 - type Reference
 - type Relationship
 - type RelationshipType
 - type Relationships
 - type Replacer
 - type Schema
 - func (schema *Schema) LookIndex(name string) *Index
 - func (schema Schema) LookUpField(name string) *Field
 - func (schema Schema) MakeSlice() reflect.Value
 - func (schema *Schema) ParseCheckConstraints() map[string]Check
 - func (schema *Schema) ParseField(fieldStruct reflect.StructField) *Field
 - func (schema *Schema) ParseIndexes() map[string]Index
 - func (schema Schema) String() string
 
- type Tabler
 - type TimeType
 - type UpdateClausesInterface
 
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupportedDataType = errors.New("unsupported data type")
    ErrUnsupportedDataType unsupported data type
var TimeReflectType = reflect.TypeOf(time.Time{})
    Functions ¶
func GetIdentityFieldValuesMap ¶
func GetIdentityFieldValuesMap(reflectValue reflect.Value, fields []*Field) (map[string][]reflect.Value, [][]interface{})
GetIdentityFieldValuesMap get identity map from fields
func GetIdentityFieldValuesMapFromValues ¶
func GetIdentityFieldValuesMapFromValues(values []interface{}, fields []*Field) (map[string][]reflect.Value, [][]interface{})
    GetIdentityFieldValuesMapFromValues get identity map from fields
func GetRelationsValues ¶
func GetRelationsValues(reflectValue reflect.Value, rels []*Relationship) (reflectResults reflect.Value)
GetRelationsValues get relations's values from a reflect value
func ToQueryValues ¶
func ToQueryValues(table string, foreignKeys []string, foreignValues [][]interface{}) (interface{}, []interface{})
ToQueryValues to query values
Types ¶
type Constraint ¶
type CreateClausesInterface ¶
type DataTypeInterface ¶
type DataTypeInterface interface {
	DaoDataType() string
}
    type DeleteClausesInterface ¶
type Field ¶
type Field struct {
	Name                   string
	DBName                 string
	BindNames              []string
	DataType               DataType
	DAODataType            DataType
	PrimaryKey             bool
	AutoIncrement          bool
	AutoIncrementIncrement int64
	Creatable              bool
	Updatable              bool
	Readable               bool
	HasDefaultValue        bool
	AutoCreateTime         TimeType
	AutoUpdateTime         TimeType
	DefaultValue           string
	DefaultValueInterface  interface{}
	NotNull                bool
	Unique                 bool
	Comment                string
	Size                   int
	Precision              int
	Scale                  int
	FieldType              reflect.Type
	IndirectFieldType      reflect.Type
	StructField            reflect.StructField
	Tag                    reflect.StructTag
	TagSettings            map[string]string
	Schema                 *Schema
	EmbeddedSchema         *Schema
	OwnerSchema            *Schema
	ReflectValueOf         func(reflect.Value) reflect.Value
	ValueOf                func(reflect.Value) (value interface{}, zero bool)
	Set                    func(reflect.Value, interface{}) error
	IgnoreMigration        bool
}
    type IndexOption ¶
type Namer ¶
type Namer interface {
	TableName(table string) string
	ColumnName(table, column string) string
	JoinTableName(joinTable string) string
	RelationshipFKName(Relationship) string
	CheckerName(table, column string) string
	IndexName(table, column string) string
}
    Namer namer interface
type NamingStrategy ¶
type NamingStrategy struct {
	TablePrefix   string
	SingularTable bool
	NameReplacer  Replacer
	NoLowerCase   bool
}
    NamingStrategy tables, columns naming strategy
func (NamingStrategy) CheckerName ¶
func (ns NamingStrategy) CheckerName(table, column string) string
CheckerName generate checker name
func (NamingStrategy) ColumnName ¶
func (ns NamingStrategy) ColumnName(table, column string) string
ColumnName convert string to column name
func (NamingStrategy) IndexName ¶
func (ns NamingStrategy) IndexName(table, column string) string
IndexName generate index name
func (NamingStrategy) JoinTableName ¶
func (ns NamingStrategy) JoinTableName(str string) string
JoinTableName convert string to join table name
func (NamingStrategy) RelationshipFKName ¶
func (ns NamingStrategy) RelationshipFKName(rel Relationship) string
RelationshipFKName generate fk name for relation
func (NamingStrategy) TableName ¶
func (ns NamingStrategy) TableName(str string) string
TableName convert string to table name
type Polymorphic ¶
type QueryClausesInterface ¶
type Relationship ¶
type Relationship struct {
	Name        string
	Type        RelationshipType
	Field       *Field
	Polymorphic *Polymorphic
	References  []*Reference
	Schema      *Schema
	FieldSchema *Schema
	JoinTable   *Schema
	// contains filtered or unexported fields
}
    func (*Relationship) ParseConstraint ¶
func (rel *Relationship) ParseConstraint() *Constraint
func (*Relationship) ToQueryConditions ¶
func (rel *Relationship) ToQueryConditions(reflectValue reflect.Value) (conds []clause.Expression)
type RelationshipType ¶
type RelationshipType string
RelationshipType relationship type
const ( HasOne RelationshipType = "has_one" // HasOneRel has one relationship HasMany RelationshipType = "has_many" // HasManyRel has many relationship BelongsTo RelationshipType = "belongs_to" // BelongsToRel belongs to relationship Many2Many RelationshipType = "many_to_many" // Many2ManyRel many to many relationship )
type Relationships ¶
type Relationships struct {
	HasOne    []*Relationship
	BelongsTo []*Relationship
	HasMany   []*Relationship
	Many2Many []*Relationship
	Relations map[string]*Relationship
}
    type Schema ¶
type Schema struct {
	Name                      string
	ModelType                 reflect.Type
	Table                     string
	PrioritizedPrimaryField   *Field
	DBNames                   []string
	PrimaryFields             []*Field
	PrimaryFieldDBNames       []string
	Fields                    []*Field
	FieldsByName              map[string]*Field
	FieldsByDBName            map[string]*Field
	FieldsWithDefaultDBValue  []*Field // fields with default value assigned by database
	Relationships             Relationships
	CreateClauses             []clause.Interface
	QueryClauses              []clause.Interface
	UpdateClauses             []clause.Interface
	DeleteClauses             []clause.Interface
	BeforeCreate, AfterCreate bool
	BeforeUpdate, AfterUpdate bool
	BeforeDelete, AfterDelete bool
	BeforeSave, AfterSave     bool
	AfterFind                 bool
	// contains filtered or unexported fields
}
    func (Schema) LookUpField ¶
func (*Schema) ParseCheckConstraints ¶
ParseCheckConstraints parse schema check constraints
func (*Schema) ParseField ¶
func (schema *Schema) ParseField(fieldStruct reflect.StructField) *Field
func (*Schema) ParseIndexes ¶
ParseIndexes parse schema indexes