define

package
v0.0.0-...-96504fd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Define

type Define struct {
	Fields    Fields                    `json:"fields"`
	Extend    ztype.Map                 `json:"extend"`
	Relations map[string]*ModelRelation `json:"relations"`
	// Hook      func(name string, m *Model) error `json:"-"`
	Table   Table        `json:"table"`
	Name    string       `json:"name"`
	Values  ztype.Maps   `json:"values"`
	Options ModelOptions `json:"options"`
}

type Field

type Field struct {
	Default     interface{}     `json:"default"`
	Unique      interface{}     `json:"unique"`
	Index       interface{}     `json:"index"`
	Comment     string          `json:"comment"`
	Label       string          `json:"label"`
	Type        schema.DataType `json:"type"`
	Validations []Validations   `json:"validations"`
	Options     FieldOption     `json:"ModelOptions"`
	Before      []string        `json:"before"`
	After       []string        `json:"after"`
	ValidRules  zvalid.Engine
	Size        uint64 `json:"size"`
	Nullable    bool   `json:"nullable"`
}

func (*Field) GetValidations

func (f *Field) GetValidations() *zvalid.Engine

type FieldEnum

type FieldEnum struct {
	Value string `json:"value"`
	Label string `json:"label"`
}

type FieldOption

type FieldOption struct {
	FormatTime       string      `json:"format_time"`
	Crypt            string      `json:"crypt"`
	Enum             []FieldEnum `json:"enum"`
	IsArray          bool        `json:"is_array"`
	ReadOnly         bool        `json:"readonly"`
	DisableMigration bool        `json:"disable_migration"`
}

type Fields

type Fields map[string]Field

type ModelOptions

type ModelOptions struct {
	Salt             string   `json:"crypt_salt"`
	LowFields        []string `json:"low_fields"`
	FieldsSort       []string `json:"fields_sort"`
	CryptLen         int      `json:"crypt_len"`
	DisabledMigrator bool     `json:"disabled_migrator"`
	SoftDeletes      bool     `json:"soft_deletes"`
	Timestamps       bool     `json:"timestamps"`
	CryptID          bool     `json:"crypt_id"`
}

type ModelRelation

type ModelRelation struct {
	Name    string             `json:"name"`
	Type    string             `json:"type"`
	Join    builder.JoinOption `json:"-"`
	Model   string             `json:"model"`
	Foreign string             `json:"foreign"`
	Key     string             `json:"key"`
	Fields  []string           `json:"Fields"`
	Limit   int                `json:"limit"`
}

type Table

type Table struct {
	Name    string `json:"name"`
	Comment string `json:"comment"`
}

type Validations

type Validations struct {
	Args    interface{} `json:"args"`
	Method  string      `json:"method"`
	Message string      `json:"message"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL