Documentation ¶
Index ¶
- Constants
- type Field
- type FieldEnum
- type FieldOption
- type Fields
- type Options
- func (o *Options) SetCryptID(b bool) *Options
- func (o *Options) SetCryptLen(i int) *Options
- func (o *Options) SetDisabledMigrator(b bool) *Options
- func (o *Options) SetHook(h func(event hook.Event, data ...any) error) *Options
- func (o *Options) SetSalt(s string) *Options
- func (o *Options) SetSoftDeletes(b bool) *Options
- func (o *Options) SetTimestamps(b bool) *Options
- type Relation
- type RelationType
- type Relations
- type Schema
- func (d *Schema) AddField(name string, field Field) error
- func (d *Schema) AddRelation(name string, relation Relation) error
- func (d *Schema) GetField(name string) (Field, bool)
- func (d *Schema) GetOptions() Options
- func (d *Schema) SetComment(comment string)
- func (d *Schema) SetOptions(fn ...func(opt *Options)) *Options
- type Schemas
- type Table
- type Validations
Constants ¶
View Source
const ( Bool = schema.Bool Int = schema.Int Int8 = schema.Int8 Int16 = schema.Int16 Int32 = schema.Int32 Int64 = schema.Int64 Uint = schema.Uint Uint8 = schema.Uint8 Uint16 = schema.Uint16 Uint32 = schema.Uint32 Uint64 = schema.Uint64 Float = schema.Float String = schema.String Text = schema.Text JSON = schema.JSON Time = schema.Time Bytes = schema.Bytes )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Field ¶
type Field struct { Default interface{} `json:"default,omitempty"` Unique interface{} `json:"unique,omitempty"` Index interface{} `json:"index,omitempty"` Comment string `json:"comment,omitempty"` Label string `json:"label"` Type schema.DataType `json:"type"` Validations []Validations `json:"validations,omitempty"` Options FieldOption `json:"options,omitempty"` Before []string `json:"-"` After []string `json:"-"` ValidRules zvalid.Engine `json:"-"` // 如果是数字类型则为长度,如果是字符串类型则为最大长度 Size uint64 `json:"size,omitempty"` Nullable bool `json:"nullable,omitempty"` }
func (*Field) GetValidations ¶
type FieldOption ¶
type Options ¶
type Options struct { DisabledMigrator *bool `json:"disabled_migrator,omitempty"` SoftDeletes *bool `json:"soft_deletes,omitempty"` Timestamps *bool `json:"timestamps,omitempty"` CryptID *bool `json:"crypt_id,omitempty"` Hook func(event hook.Event, data ...any) error Salt string `json:"crypt_salt,omitempty"` LowFields []string `json:"low_fields,omitempty"` FieldsSort []string `json:"fields_sort,omitempty"` CryptLen int `json:"crypt_len,omitempty"` }
func (*Options) SetCryptID ¶
func (*Options) SetCryptLen ¶
func (*Options) SetDisabledMigrator ¶
func (*Options) SetSoftDeletes ¶
func (*Options) SetTimestamps ¶
type Relation ¶
type Relation struct { Filter ztype.Map `json:"filter,omitempty"` Comment string `json:"comment,omitempty"` Label string `json:"label"` Type RelationType `json:"type"` Join builder.JoinOption `json:"-"` Schema string `json:"schema"` ForeignKey []string `json:"foreign_key"` SchemaKey []string `json:"schema_key"` Fields []string `json:"fields,omitempty"` Nullable bool `json:"nullable,omitempty"` }
type RelationType ¶
type RelationType string
const ( // RelationSingle 单对单 RelationSingle RelationType = "single" // RelationSingleMerge 单对单,结果合并 RelationSingleMerge RelationType = "single_merge" // RelationMany 单对多 RelationMany RelationType = "many" )
type Schema ¶
type Schema struct { Options Options `json:"options,omitempty"` Fields Fields `json:"fields"` Extend ztype.Map `json:"extend,omitempty"` Relations Relations `json:"relations,omitempty"` Table Table `json:"table,omitempty"` Name string `json:"name"` SchemaPath string `json:"-"` Values ztype.Maps `json:"values,omitempty"` }
func (*Schema) GetOptions ¶
func (*Schema) SetComment ¶
func (*Schema) SetOptions ¶
type Validations ¶
Click to show internal directories.
Click to hide internal directories.