model

package
v0.0.0-...-a09fd22 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TablePrefix       = "bigstruct"
	RefSeparator      = '='
	ModelBeforeCreate = RandomID
)

Functions

func ParseRef

func ParseRef(ref string) (name, prop string, err error)

func RandomID

func RandomID(m *Model, db *gorm.DB) error

func Ref

func Ref(name, prop string) string

Types

type Index

type Index struct {
	Model    `yaml:",inline"`
	Name     string `gorm:"column:name;type:tinytext;not null" yaml:"name,omitempty" json:"name,omitempty"`
	Property string `gorm:"column:property;type:tinytext;not null" yaml:"property,omitempty" json:"property,omitempty"`
	Index    Object `gorm:"column:index;type:text;not null" yaml:"index,omitempty" json:"index,omitempty"`
	Metadata Object `gorm:"column:metadata;type:text" yaml:"metadata,omitempty" json:"metadata,omitempty"`
}

func (*Index) Ref

func (i *Index) Ref() string

func (*Index) SetRef

func (i *Index) SetRef(ref string) error

func (*Index) TableName

func (*Index) TableName() string

type Indexes

type Indexes []*Index

func (Indexes) String

func (i Indexes) String() string

func (Indexes) WriteTab

func (i Indexes) WriteTab(w io.Writer) (int64, error)

func (Indexes) WriteTo

func (i Indexes) WriteTo(w io.Writer) (int64, error)

type Model

type Model struct {
	ID        uint64         `gorm:"column:id;type:bigint;not null;primaryKey;autoIncrement" yaml:"id,omitempty" json:"id,omitempty"`
	CreatedAt time.Time      `gorm:"column:created_at;type:datetime;not null" yaml:"created_at,omitempty" json:"created_at,omitempty"`
	UpdatedAt time.Time      `gorm:"column:updated_at;type:datetime;not null" yaml:"updated_at,omitempty" json:"updated_at,omitempty"`
	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime;index" yaml:"deleted_at,omitempty" json:"deleted_at,omitempty"`
}

func (*Model) BeforeCreate

func (m *Model) BeforeCreate(db *gorm.DB) error

func (*Model) Options

func (*Model) Options() []string

type Object

type Object string

func (Object) Equal

func (obj Object) Equal(ubj Object) bool

func (Object) Map

func (obj Object) Map() map[string]interface{}

func (Object) MarshalJSON

func (obj Object) MarshalJSON() ([]byte, error)

func (Object) MarshalYAML

func (obj Object) MarshalYAML() (interface{}, error)

func (*Object) Merge

func (obj *Object) Merge(v map[string]interface{}) Object

func (*Object) Set

func (obj *Object) Set(v interface{}) Object

func (*Object) SetValues

func (obj *Object) SetValues(kv ...interface{}) Object

func (Object) String

func (obj Object) String() string

func (Object) Unmarshal

func (obj Object) Unmarshal(v interface{}) error

func (*Object) UnmarshalJSON

func (obj *Object) UnmarshalJSON(p []byte) error

func (*Object) UnmarshalYAML

func (obj *Object) UnmarshalYAML(n *yaml.Node) error

func (*Object) Update

func (obj *Object) Update(ubj Object) bool

type Overlay

type Overlay struct {
	Model    `yaml:",inline"`
	Name     string `gorm:"column:name;type:tinytext;not null" yaml:"name,omitempty" json:"name,omitempty"`
	Property string `gorm:"-" yaml:"property,omitempty" json:"property,omitempty"`
	Priority int    `gorm:"column:priority;type:smallint;not null" yaml:"priority,omitempty" json:"priority,omitempty"`
	Metadata Object `gorm:"column:metadata;type:text" yaml:"metadata,omitempty" json:"metadata,omitempty"`
}

func (*Overlay) Copy

func (o *Overlay) Copy() *Overlay

func (*Overlay) Meta

func (o *Overlay) Meta() *OverlayMeta

func (*Overlay) Ref

func (o *Overlay) Ref() string

func (*Overlay) SetProperty

func (o *Overlay) SetProperty(prop string) error

func (*Overlay) SetRef

func (o *Overlay) SetRef(ref string) error

func (*Overlay) TableName

func (*Overlay) TableName() string

type OverlayMeta

type OverlayMeta struct {
	NoProperty bool `json:"no_property,omitempty"`
	Schema     bool `json:"schema,omitempty"`
}

func (*OverlayMeta) JSON

func (om *OverlayMeta) JSON() types.JSON

func (*OverlayMeta) Metadata

func (om *OverlayMeta) Metadata() Object

type Overlays

type Overlays []*Overlay

func (Overlays) ByName

func (os Overlays) ByName(name string) *Overlay

func (Overlays) ByRef

func (os Overlays) ByRef(ref string) *Overlay

func (Overlays) String

func (os Overlays) String() string

func (Overlays) WriteTab

func (os Overlays) WriteTab(w io.Writer) (int64, error)

func (Overlays) WriteTo

func (os Overlays) WriteTo(w io.Writer) (int64, error)

type Schema

type Schema struct {
	Model           `yaml:",inline"`
	Overlay         *Overlay `yaml:"-" json:"-"`
	OverlayID       uint64   `gorm:"column:overlay_id;type:bigint;not null;index" yaml:"overlay_id,omitempty" json:"overlay_id,omitempty"`
	OverlayProperty string   `gorm:"column:overlay_property;type:tinytext;not null" yaml:"overlay_property,omitempty" json:"overlay_property,omitempty"`
	Key             string   `gorm:"column:key;type:text;not null" yaml:"key,omitempty" json:"key,omitempty"`
	Type            string   `gorm:"column:type;type:tinytext;not null" yaml:"type,omitempty" json:"type,omitempty"`
	Encoding        string   `gorm:"column:encoding;type:tinytext;not null" yaml:"encoding,omitempty" json:"encoding,omitempty"`
	Metadata        Object   `gorm:"column:metadata;type:text" yaml:"metadata,omitempty" json:"metadata,omitempty"`
}

func (*Schema) Codec

func (s *Schema) Codec() string

func (*Schema) TableName

func (*Schema) TableName() string

type Schemas

type Schemas []*Schema

func MakeSchemas

func MakeSchemas(o *Overlay, f big.Fields) Schemas

func (Schemas) Fields

func (s Schemas) Fields() big.Fields

func (Schemas) SetMeta

func (s Schemas) SetMeta(meta Object)

func (Schemas) SetOverlay

func (s Schemas) SetOverlay(o *Overlay)

func (Schemas) String

func (s Schemas) String() string

func (Schemas) WriteTab

func (s Schemas) WriteTab(w io.Writer) (int64, error)

func (Schemas) WriteTo

func (s Schemas) WriteTo(w io.Writer) (int64, error)

type Value

type Value struct {
	Model           `yaml:",inline"`
	Overlay         *Overlay `gorm:"" yaml:"-" json:"-"`
	OverlayID       uint64   `gorm:"column:overlay_id;type:bigint;not null;index" yaml:"overlay_id,omitempty" json:"overlay_id,omitempty"`
	OverlayProperty string   `gorm:"column:overlay_property;type:tinytext;not null" yaml:"overlay_property,omitempty" json:"overlay_property,omitempty"`
	Key             string   `gorm:"column:key;type:text;not null" yaml:"key,omitempty" json:"key,omitempty"`
	RawValue        string   `gorm:"column:value;type:text" yaml:"value,omitempty" json:"value,omitempty"`
	Metadata        Object   `gorm:"column:metadata;type:text" yaml:"metadata,omitempty" json:"metadata,omitempty"`
}

func (*Value) SetValue

func (v *Value) SetValue(w interface{})

func (*Value) TableName

func (*Value) TableName() string

func (*Value) Value

func (v *Value) Value() interface{}

type Values

type Values []*Value

func MakeValues

func MakeValues(o *Overlay, f big.Fields) Values

func (Values) Fields

func (v Values) Fields() big.Fields

func (Values) SetMeta

func (v Values) SetMeta(meta Object)

func (Values) SetOverlay

func (v Values) SetOverlay(o *Overlay)

func (Values) String

func (v Values) String() string

func (Values) WriteTab

func (v Values) WriteTab(w io.Writer) (int64, error)

func (Values) WriteTo

func (v Values) WriteTo(w io.Writer) (int64, error)

Jump to

Keyboard shortcuts

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