models

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FieldTypeBool = iota + 1
	FieldTypeEnum
	FieldTypeInt
	FieldTypeSmallInt
	FieldTypeBigInt
	FieldTypeFloat32
	FieldTypeFloat64
	FieldTypeString
	FieldTypeTime
	FieldTypeUUID
	FieldTypeUint
)
View Source
const (
	RelationTypeManyToOne = iota
	RelationTypeOneToMany
	RelationTypeManyToMany
)

Variables

This section is empty.

Functions

func ConvertToSnakeCase

func ConvertToSnakeCase(input string) string

Types

type BoolDBField

type BoolDBField struct {
	*Field
	DefaultValue      bool
	DefaultFuncStruct *FuncStruct
}

func BoolField

func BoolField(name string) *BoolDBField

func (*BoolDBField) Default

func (i *BoolDBField) Default(v bool) *BoolDBField

func (*BoolDBField) DefaultFunc

func (i *BoolDBField) DefaultFunc(v func() bool) *BoolDBField

func (*BoolDBField) GetDefault

func (i *BoolDBField) GetDefault() string

func (*BoolDBField) SetDBName

func (i *BoolDBField) SetDBName(v string) *BoolDBField

type EnumDBField

type EnumDBField struct {
	*Field
	DefaultValue      string
	DefaultFuncStruct *FuncStruct
	TypeName          string
	Values            []string
}

func EnumField

func EnumField(name string, values []string) *EnumDBField

func (*EnumDBField) Default

func (s *EnumDBField) Default(v string) *EnumDBField

func (*EnumDBField) DefaultFunc

func (s *EnumDBField) DefaultFunc(v func() string) *EnumDBField

func (*EnumDBField) GetDefault

func (s *EnumDBField) GetDefault() string

func (*EnumDBField) SetDBName

func (s *EnumDBField) SetDBName(v string) *EnumDBField

type Field

type Field struct {
	FieldType        int
	Name             string
	DBName           string
	Type             string
	BaseType         string
	Nillable         bool
	HaveDefault      bool
	IsPrepare        bool
	IsGreater        bool
	HaveCustomType   bool
	IsTime           bool
	IsUUID           bool
	Serial           bool
	RequiredPackages []string
}

func (*Field) CanBeGreater

func (f *Field) CanBeGreater() bool

func (*Field) CanTime

func (f *Field) CanTime() bool

func (*Field) CanUUID

func (f *Field) CanUUID() bool

func (*Field) GetAddressType

func (f *Field) GetAddressType() string

func (*Field) GetBaseType

func (f *Field) GetBaseType() string

func (*Field) GetDBName

func (f *Field) GetDBName() string

func (*Field) GetFieldType

func (f *Field) GetFieldType() int

func (*Field) GetName

func (f *Field) GetName() string

func (*Field) GetNameLower

func (f *Field) GetNameLower() string

func (*Field) GetNameTitle

func (f *Field) GetNameTitle() string

func (*Field) GetRequiredPackages

func (f *Field) GetRequiredPackages() []string

func (*Field) GetType

func (f *Field) GetType() string

func (*Field) IsCustomType

func (f *Field) IsCustomType() bool

func (*Field) IsDefault

func (f *Field) IsDefault() bool

func (*Field) IsNillable

func (f *Field) IsNillable() bool

func (*Field) IsSerial

func (f *Field) IsSerial() bool

func (*Field) NeedPrepare

func (f *Field) NeedPrepare() bool

func (*Field) SetDBName

func (f *Field) SetDBName(v string)

func (*Field) SetDBNameManually

func (f *Field) SetDBNameManually(name string)

func (*Field) SetNillable

func (f *Field) SetNillable() *Field

type FieldI

type FieldI interface {
	GetRequiredPackages() []string
	GetFieldType() int
	GetType() string
	GetName() string
	GetDBName() string
	IsNillable() bool
	IsSerial() bool
}

type Float32DBField

type Float32DBField struct {
	*Field
	DefaultValue      int
	DefaultFuncStruct *FuncStruct
}

func Float32Field

func Float32Field(name string) *Float32DBField

func (*Float32DBField) Default

func (i *Float32DBField) Default(v int) *Float32DBField

func (*Float32DBField) DefaultFunc

func (i *Float32DBField) DefaultFunc(v func() int) *Float32DBField

func (*Float32DBField) GetDefault

func (i *Float32DBField) GetDefault() string

func (*Float32DBField) SetDBName

func (i *Float32DBField) SetDBName(v string) *Float32DBField

type Float64DBField

type Float64DBField struct {
	*Field
	DefaultValue      int
	DefaultFuncStruct *FuncStruct
}

func Float64Field

func Float64Field(name string) *Float64DBField

func (*Float64DBField) Default

func (i *Float64DBField) Default(v int) *Float64DBField

func (*Float64DBField) DefaultFunc

func (i *Float64DBField) DefaultFunc(v func() int) *Float64DBField

func (*Float64DBField) GetDefault

func (i *Float64DBField) GetDefault() string

func (*Float64DBField) SetDBName

func (i *Float64DBField) SetDBName(v string) *Float64DBField

type FuncStruct

type FuncStruct struct {
	PackageAddress string
	PackageFunc    string
}

func (*FuncStruct) DefaultFunc

func (f *FuncStruct) DefaultFunc(v any)

type Generation

type Generation struct {
	Tables []*Table
}

type IntDBField

type IntDBField struct {
	*Field
	DefaultValue      int
	DefaultFuncStruct *FuncStruct
}

func IntField

func IntField(name string) *IntDBField

func (*IntDBField) AddSerial

func (i *IntDBField) AddSerial() *IntDBField

func (*IntDBField) Default

func (i *IntDBField) Default(v int) *IntDBField

func (*IntDBField) DefaultFunc

func (i *IntDBField) DefaultFunc(v func() int) *IntDBField

func (*IntDBField) GetDefault

func (i *IntDBField) GetDefault() string

func (*IntDBField) SetDBName

func (i *IntDBField) SetDBName(v string) *IntDBField

type Relation

type Relation struct {
	RelationTable       string
	RelationTableDBName string
	RelationField       string
	OnField             string
	ManyTableDBName     string
	RelationTableField  string
	RelationType        int
}

func ManyToMany

func ManyToMany(table, toField, fromField, relationField, manyTableName string) *Relation

func ManyToOne

func ManyToOne(table, toField, fromField string) *Relation

func OneToMany

func OneToMany(table, toField, fromField string) *Relation

func (*Relation) GetRelationField

func (r *Relation) GetRelationField() string

func (*Relation) GetRelationTableLower

func (r *Relation) GetRelationTableLower() string

func (*Relation) IsManyToMany

func (r *Relation) IsManyToMany() bool

func (*Relation) IsRelationList

func (r *Relation) IsRelationList() bool

type StringDBField

type StringDBField struct {
	*Field
	DefaultValue      string
	DefaultFuncStruct *FuncStruct
}

func StringField

func StringField(name string) *StringDBField

func (*StringDBField) Default

func (s *StringDBField) Default(v string) *StringDBField

func (*StringDBField) DefaultFunc

func (s *StringDBField) DefaultFunc(v func() string) *StringDBField

func (*StringDBField) GetDefault

func (s *StringDBField) GetDefault() string

func (*StringDBField) SetDBName

func (s *StringDBField) SetDBName(v string) *StringDBField

type Table

type Table struct {
	PackageName      string
	TableName        string
	DBName           string
	IDField          string
	IDDBField        string
	IDFieldType      string
	Fields           []FieldI
	Relations        []*Relation
	IDColumn         FieldI
	RequiredPackages []string
}

func (*Table) IDFieldLower

func (t *Table) IDFieldLower() string

func (*Table) SetIDField

func (t *Table) SetIDField(field FieldI)

func (*Table) SetTableName

func (t *Table) SetTableName(name string)

type TimeDBField

type TimeDBField struct {
	*Field
	DefaultFuncStruct *FuncStruct
}

func TimeField

func TimeField(name string) *TimeDBField

func (*TimeDBField) DefaultFunc

func (t *TimeDBField) DefaultFunc(v func() time.Time) *TimeDBField

func (*TimeDBField) GetDefault

func (t *TimeDBField) GetDefault() string

func (*TimeDBField) PrepareFunc

func (t *TimeDBField) PrepareFunc() string

func (*TimeDBField) SetDBName

func (t *TimeDBField) SetDBName(v string) *TimeDBField

func (*TimeDBField) SetNillable

func (t *TimeDBField) SetNillable() *TimeDBField

type UUIDDBField

type UUIDDBField struct {
	*Field
	DefaultFuncStruct *FuncStruct
}

func UUIDField

func UUIDField(name string) *UUIDDBField

func (*UUIDDBField) DefaultFunc

func (u *UUIDDBField) DefaultFunc(v func() uuid.UUID) *UUIDDBField

func (*UUIDDBField) GetDefault

func (u *UUIDDBField) GetDefault() string

func (*UUIDDBField) PrepareFunc

func (u *UUIDDBField) PrepareFunc() string

func (*UUIDDBField) SetDBName

func (u *UUIDDBField) SetDBName(v string) *UUIDDBField

func (*UUIDDBField) SetNillable

func (u *UUIDDBField) SetNillable() *UUIDDBField

type UintDBField

type UintDBField struct {
	*Field
	DefaultValue      uint
	DefaultFuncStruct *FuncStruct
}

func UintField

func UintField(name string) *UintDBField

func (*UintDBField) AddSerial

func (i *UintDBField) AddSerial() *UintDBField

func (*UintDBField) Default

func (i *UintDBField) Default(v uint) *UintDBField

func (*UintDBField) DefaultFunc

func (i *UintDBField) DefaultFunc(v func() uint) *UintDBField

func (*UintDBField) GetDefault

func (i *UintDBField) GetDefault() string

func (*UintDBField) SetDBName

func (i *UintDBField) SetDBName(v string) *UintDBField

Jump to

Keyboard shortcuts

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