package schema
Import Path
gorm.io/gorm/schema (on go.dev )
Dependency Relation
imports 27 packages , and imported by 6 packages
Package-Level Type Names (total 31)
/* sort by: alphabet | popularity */
type CheckConstraint (struct)
Fields (total 40 )
Constraint string
// length(phone) >= 10
Field *Field
Field .AutoCreateTime TimeType
Field .AutoIncrement bool
Field .AutoIncrementIncrement int64
Field .AutoUpdateTime TimeType
Field .BindNames []string
Field .Comment string
Field .Creatable bool
Field .DBName string
Field .DataType DataType
Field .DefaultValue string
Field .DefaultValueInterface interface{}
Field .EmbeddedBindNames []string
Field .EmbeddedSchema *Schema
Field .FieldType reflect .Type
Field .GORMDataType DataType
Field .HasDefaultValue bool
Field .IgnoreMigration bool
Field .IndirectFieldType reflect .Type
Field .NewValuePool FieldNewValuePool
Field .NotNull bool
Field .OwnerSchema *Schema
Field .Precision int
Field .PrimaryKey bool
Field .Readable bool
Field .ReflectValueOf func(context .Context , reflect .Value ) reflect .Value
Field .Scale int
Field .Schema *Schema
Field .Serializer SerializerInterface
Field .Set func(context .Context , reflect .Value , interface{}) error
Field .Size int
Field .StructField reflect .StructField
Field .Tag reflect .StructTag
Field .TagSettings map[string ]string
Field .Unique bool
Field .UniqueIndex string
In some db (e.g. MySQL), Unique and UniqueIndex are indistinguishable.
When a column has a (not Mul) UniqueIndex, Migrator always reports its gorm.ColumnType is Unique.
It causes field unnecessarily migration.
Therefore, we need to record the UniqueIndex on this column (exclude Mul UniqueIndex) for MigrateColumnUnique.
Field .Updatable bool
Field .ValueOf func(context .Context , reflect .Value ) (value interface{}, zero bool )
Name string
Methods (total 3 )
( CheckConstraint) BindName () string
(*CheckConstraint) Build () (sql string , vars []interface{})
(*CheckConstraint) GetName () string
Implements (at least one exported )
*CheckConstraint : ConstraintInterface
As Outputs Of (at least 2 )
func (*Schema ).ParseCheckConstraints () map[string ]CheckConstraint
func gorm.io/gorm/migrator.Migrator .GuessConstraintAndTable (stmt *gorm .Statement , name string ) (*Constraint , *CheckConstraint , string )
type Field (struct)
Field is the representation of model schema's field
Fields (total 38 )
AutoCreateTime TimeType
AutoIncrement bool
AutoIncrementIncrement int64
AutoUpdateTime TimeType
BindNames []string
Comment string
Creatable bool
DBName string
DataType DataType
DefaultValue string
DefaultValueInterface interface{}
EmbeddedBindNames []string
EmbeddedSchema *Schema
FieldType reflect .Type
GORMDataType DataType
HasDefaultValue bool
IgnoreMigration bool
IndirectFieldType reflect .Type
Name string
NewValuePool FieldNewValuePool
NotNull bool
OwnerSchema *Schema
Precision int
PrimaryKey bool
Readable bool
ReflectValueOf func(context .Context , reflect .Value ) reflect .Value
Scale int
Schema *Schema
Serializer SerializerInterface
Set func(context .Context , reflect .Value , interface{}) error
Size int
StructField reflect .StructField
Tag reflect .StructTag
TagSettings map[string ]string
Unique bool
UniqueIndex string
In some db (e.g. MySQL), Unique and UniqueIndex are indistinguishable.
When a column has a (not Mul) UniqueIndex, Migrator always reports its gorm.ColumnType is Unique.
It causes field unnecessarily migration.
Therefore, we need to record the UniqueIndex on this column (exclude Mul UniqueIndex) for MigrateColumnUnique.
Updatable bool
ValueOf func(context .Context , reflect .Value ) (value interface{}, zero bool )
Methods (only one )
(*Field) BindName () string
As Outputs Of (at least 3 )
func (*Schema ).LookUpField (name string ) *Field
func (*Schema ).LookUpFieldByBindName (bindNames []string , name string ) *Field
func (*Schema ).ParseField (fieldStruct reflect .StructField ) *Field
As Inputs Of (at least 40 )
func GetIdentityFieldValuesMap (ctx context .Context , reflectValue reflect .Value , fields []*Field ) (map[string ][]reflect .Value , [][]interface{})
func GetIdentityFieldValuesMapFromValues (ctx context .Context , values []interface{}, fields []*Field ) (map[string ][]reflect .Value , [][]interface{})
func CreateClausesInterface .CreateClauses (*Field ) []clause .Interface
func DeleteClausesInterface .DeleteClauses (*Field ) []clause .Interface
func GobSerializer .Scan (ctx context .Context , field *Field , dst reflect .Value , dbValue interface{}) (err error )
func GobSerializer .Value (ctx context .Context , field *Field , dst reflect .Value , fieldValue interface{}) (interface{}, error )
func JSONSerializer .Scan (ctx context .Context , field *Field , dst reflect .Value , dbValue interface{}) (err error )
func JSONSerializer .Value (ctx context .Context , field *Field , dst reflect .Value , fieldValue interface{}) (interface{}, error )
func QueryClausesInterface .QueryClauses (*Field ) []clause .Interface
func SerializerInterface .Scan (ctx context .Context , field *Field , dst reflect .Value , dbValue interface{}) error
func SerializerInterface .Value (ctx context .Context , field *Field , dst reflect .Value , fieldValue interface{}) (interface{}, error )
func SerializerValuerInterface .Value (ctx context .Context , field *Field , dst reflect .Value , fieldValue interface{}) (interface{}, error )
func UnixSecondSerializer .Scan (ctx context .Context , field *Field , dst reflect .Value , dbValue interface{}) (err error )
func UnixSecondSerializer .Value (ctx context .Context , field *Field , dst reflect .Value , fieldValue interface{}) (result interface{}, err error )
func UpdateClausesInterface .UpdateClauses (*Field ) []clause .Interface
func gorm.io/gorm.DeletedAt .DeleteClauses (f *Field ) []clause .Interface
func gorm.io/gorm.DeletedAt .QueryClauses (f *Field ) []clause .Interface
func gorm.io/gorm.DeletedAt .UpdateClauses (f *Field ) []clause .Interface
func gorm.io/gorm.Dialector .DataTypeOf (*Field ) string
func gorm.io/gorm.Dialector .DefaultValueOf (*Field ) clause .Expression
func gorm.io/gorm.Migrator .FullDataTypeOf (*Field ) clause .Expr
func gorm.io/gorm.Migrator .MigrateColumn (dst interface{}, field *Field , columnType gorm .ColumnType ) error
func gorm.io/gorm.Migrator .MigrateColumnUnique (dst interface{}, field *Field , columnType gorm .ColumnType ) error
func gorm.io/gorm/migrator.GormDataTypeInterface .GormDBDataType (*gorm .DB , *Field ) string
func gorm.io/gorm/migrator.Migrator .DataTypeOf (field *Field ) string
func gorm.io/gorm/migrator.Migrator .FullDataTypeOf (field *Field ) (expr clause .Expr )
func gorm.io/gorm/migrator.Migrator .MigrateColumn (value interface{}, field *Field , columnType gorm .ColumnType ) error
func gorm.io/gorm/migrator.Migrator .MigrateColumnUnique (value interface{}, field *Field , columnType gorm .ColumnType ) error
func gorm.io/datatypes.BinUUID .GormDBDataType (db *gorm .DB , field *Field ) string
func gorm.io/datatypes.JSON .GormDBDataType (db *gorm .DB , field *Field ) string
func gorm.io/datatypes.JSONMap .GormDBDataType (db *gorm .DB , field *Field ) string
func gorm.io/datatypes.JSONSlice [T].GormDBDataType (db *gorm .DB , field *Field ) string
func gorm.io/datatypes.JSONType [T].GormDBDataType (db *gorm .DB , field *Field ) string
func gorm.io/datatypes.Time .GormDBDataType (db *gorm .DB , field *Field ) string
func gorm.io/datatypes.URL .GormDBDataType (db *gorm .DB , field *Field ) string
func gorm.io/datatypes.UUID .GormDBDataType (db *gorm .DB , field *Field ) string
func gorm.io/driver/mysql.Dialector .DataTypeOf (field *Field ) string
func gorm.io/driver/mysql.Dialector .DefaultValueOf (field *Field ) clause .Expression
func gorm.io/driver/mysql.Migrator .FullDataTypeOf (field *Field ) clause .Expr
func gorm.io/driver/mysql.Migrator .MigrateColumnUnique (value interface{}, field *Field , columnType gorm .ColumnType ) error
type IndexOption (struct)
Fields (total 44 )
Collate string
Expression string
Field *Field
Field .AutoCreateTime TimeType
Field .AutoIncrement bool
Field .AutoIncrementIncrement int64
Field .AutoUpdateTime TimeType
Field .BindNames []string
Field .Comment string
Field .Creatable bool
Field .DBName string
Field .DataType DataType
Field .DefaultValue string
Field .DefaultValueInterface interface{}
Field .EmbeddedBindNames []string
Field .EmbeddedSchema *Schema
Field .FieldType reflect .Type
Field .GORMDataType DataType
Field .HasDefaultValue bool
Field .IgnoreMigration bool
Field .IndirectFieldType reflect .Type
Field .Name string
Field .NewValuePool FieldNewValuePool
Field .NotNull bool
Field .OwnerSchema *Schema
Field .Precision int
Field .PrimaryKey bool
Field .Readable bool
Field .ReflectValueOf func(context .Context , reflect .Value ) reflect .Value
Field .Scale int
Field .Schema *Schema
Field .Serializer SerializerInterface
Field .Set func(context .Context , reflect .Value , interface{}) error
Field .Size int
Field .StructField reflect .StructField
Field .Tag reflect .StructTag
Field .TagSettings map[string ]string
Field .Unique bool
Field .UniqueIndex string
In some db (e.g. MySQL), Unique and UniqueIndex are indistinguishable.
When a column has a (not Mul) UniqueIndex, Migrator always reports its gorm.ColumnType is Unique.
It causes field unnecessarily migration.
Therefore, we need to record the UniqueIndex on this column (exclude Mul UniqueIndex) for MigrateColumnUnique.
Field .Updatable bool
Field .ValueOf func(context .Context , reflect .Value ) (value interface{}, zero bool )
Length int
Priority int
Sort string
// DESC, ASC
Methods (only one )
( IndexOption) BindName () string
As Inputs Of (at least 2 )
func gorm.io/gorm/migrator.BuildIndexOptionsInterface .BuildIndexOptions ([]IndexOption , *gorm .Statement ) []interface{}
func gorm.io/gorm/migrator.Migrator .BuildIndexOptions (opts []IndexOption , stmt *gorm .Statement ) (results []interface{})
type Namer (interface)
Namer namer interface
Methods (total 8 )
( Namer) CheckerName (table, column string ) string
( Namer) ColumnName (table, column string ) string
( Namer) IndexName (table, column string ) string
( Namer) JoinTableName (joinTable string ) string
( Namer) RelationshipFKName (Relationship ) string
( Namer) SchemaName (table string ) string
( Namer) TableName (table string ) string
( Namer) UniqueName (table, column string ) string
Implemented By (at least one exported )
NamingStrategy
As Inputs Of (at least 3 )
func Parse (dest interface{}, cacheStore *sync .Map , namer Namer ) (*Schema , error )
func ParseWithSpecialTableName (dest interface{}, cacheStore *sync .Map , namer Namer , specialTableName string ) (*Schema , error )
func TablerWithNamer .TableName (Namer ) string
type Schema (struct)
Fields (total 26 )
AfterCreate bool
AfterDelete bool
AfterFind bool
AfterSave bool
AfterUpdate bool
BeforeCreate bool
BeforeDelete bool
BeforeSave bool
BeforeUpdate bool
CreateClauses []clause .Interface
DBNames []string
DeleteClauses []clause .Interface
Fields []*Field
FieldsByBindName map[string ]*Field
// embedded fields is 'Embed.Field'
FieldsByDBName map[string ]*Field
FieldsByName map[string ]*Field
FieldsWithDefaultDBValue []*Field
// fields with default value assigned by database
ModelType reflect .Type
Name string
PrimaryFieldDBNames []string
PrimaryFields []*Field
PrioritizedPrimaryField *Field
QueryClauses []clause .Interface
Relationships Relationships
Table string
UpdateClauses []clause .Interface
Methods (total 9 )
(*Schema) LookIndex (name string ) *Index
(*Schema) LookUpField (name string ) *Field
(*Schema) LookUpFieldByBindName (bindNames []string , name string ) *Field
LookUpFieldByBindName looks for the closest field in the embedded struct.
type Struct struct {
Embedded struct {
ID string // is selected by LookUpFieldByBindName([]string{"Embedded", "ID"}, "ID")
}
ID string // is selected by LookUpFieldByBindName([]string{"ID"}, "ID")
}
(*Schema) MakeSlice () reflect .Value
(*Schema) ParseCheckConstraints () map[string ]CheckConstraint
ParseCheckConstraints parse schema check constraints
(*Schema) ParseField (fieldStruct reflect .StructField ) *Field
ParseField parses reflect.StructField to Field
(*Schema) ParseIndexes () []*Index
ParseIndexes parse schema indexes
(*Schema) ParseUniqueConstraints () map[string ]UniqueConstraint
ParseUniqueConstraints parse schema unique constraints
(*Schema) String () string
Implements (at least 2 )
*Schema : expvar.Var
*Schema : fmt.Stringer
As Outputs Of (at least 2 )
func Parse (dest interface{}, cacheStore *sync .Map , namer Namer ) (*Schema , error )
func ParseWithSpecialTableName (dest interface{}, cacheStore *sync .Map , namer Namer , specialTableName string ) (*Schema , error )
Package-Level Functions (total 9)
Package-Level Variables (total 4)
Package-Level Constants (total 16)
The pages are generated with Golds v0.8.2 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .