shared

package
v2.8.3 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NullTypes = map[string]string{
	"string":    "String",
	"bool":      "Bool",
	"int":       "Int64",
	"int32":     "Int64",
	"int64":     "Int64",
	"bit":       "Bool",
	"time.Time": "String",
	"float":     "Float64",
	"float32":   "Float64",
	"float64":   "Float64",
}
View Source
var SupportedFieldTypes = map[string]string{
	"[]string": "list<string>",
	"bool":     "bool",
	"datetime": "i64",
	"float64":  "double",
	"int":      "i32",
	"int32":    "i32",
	"int64":    "i64",
	"string":   "string",
}

Functions

func DbToGoType

func DbToGoType(colType string) string

func ToStringSlice

func ToStringSlice(val []interface{}) (result []string)

Types

type Field

type Field struct {
	Attrs        map[string]string
	DefaultValue string
	Flags        set.Set
	Index        string
	Key          string
	Label        string
	PlaceHolder  string
	Name         string
	Order        string
	Tag          string
	Type         string
	Size         int    // The field size, use for DDL generation.
	Decimal      int    // The decimal size, only use for "float64" type.
	Default      string // The default value for this field, use for DDL generation.
	Widget       string
	Remark       string
	FK           *ForeignKey
	Obj          *Obj
	AsSort       bool
	Comment      string
}

func (*Field) ArgName

func (f *Field) ArgName() string

func (*Field) AsArgName

func (f *Field) AsArgName(prefix string) string

func (*Field) AttrsContains

func (f *Field) AttrsContains(attr string) bool

func (*Field) BJTag

func (f *Field) BJTag() string

func (*Field) BsonTagName

func (f *Field) BsonTagName() string

func (*Field) DbName

func (f *Field) DbName() string

func (*Field) DisableAutoInc

func (f *Field) DisableAutoInc() bool

func (*Field) Foreign

func (f *Field) Foreign() string

func (*Field) ForeignType

func (f *Field) ForeignType() string

func (*Field) GetGoType

func (f *Field) GetGoType() string

func (*Field) GetName

func (f *Field) GetName() string

func (*Field) GetNullSQLType

func (f *Field) GetNullSQLType() string

func (*Field) GetTag

func (f *Field) GetTag() string

func (*Field) GetThriftType

func (f *Field) GetThriftType() string

func (*Field) GetTransformType

func (f *Field) GetTransformType() *Transform

func (*Field) HasBindData

func (f *Field) HasBindData() bool

func (*Field) HasDefaultValue

func (f *Field) HasDefaultValue() bool

func (*Field) HasDisable

func (f *Field) HasDisable() bool

func (*Field) HasEnums

func (f *Field) HasEnums() bool

func (*Field) HasForeign

func (f *Field) HasForeign() bool

func (*Field) HasHidden

func (f *Field) HasHidden() bool

func (*Field) HasIndex

func (f *Field) HasIndex() bool

func (*Field) HasMeta

func (f *Field) HasMeta() bool

func (*Field) HasReadOnly

func (f *Field) HasReadOnly() bool

func (*Field) HasRule

func (f *Field) HasRule() bool

func (*Field) HasStringList

func (f *Field) HasStringList() bool

func (*Field) IsAutoInc

func (f *Field) IsAutoInc() bool

func (*Field) IsNeedTransform

func (f *Field) IsNeedTransform() bool

func (*Field) IsNullable

func (f *Field) IsNullable() bool

func (*Field) IsNullablePrimitive

func (f *Field) IsNullablePrimitive() bool

func (*Field) IsRequired

func (f *Field) IsRequired() bool

func (*Field) IsUnique

func (f *Field) IsUnique() bool

func (*Field) MysqlCreation

func (f *Field) MysqlCreation() string

func (*Field) NullSQLTypeNeedCast

func (f *Field) NullSQLTypeNeedCast() bool

func (*Field) NullSQLTypeValue

func (f *Field) NullSQLTypeValue() string

func (*Field) Read

func (f *Field) Read(data generator.Schema) error

type ForeignKey

type ForeignKey struct {
	Tbl   string
	Field string
}

func NewForeignKey

func NewForeignKey(name string) *ForeignKey

type Generator

type Generator struct{}

Generator is a generator that supports mysql and mongo drivers which share the same metadata format.

func (*Generator) DriverName

func (g *Generator) DriverName() string

func (*Generator) Generate

func (g *Generator) Generate(meta generator.TMetadata) error

type Index

type Index struct {
	Name       string
	Fields     []*Field
	FieldNames []string
	IsUnique   bool
	IsSparse   bool
}

func (*Index) CanUseFindIn

func (i *Index) CanUseFindIn() bool

func (*Index) CanUseFindList

func (i *Index) CanUseFindList() bool

func (*Index) GetFieldList

func (i *Index) GetFieldList() string

func (*Index) GetFindInIds

func (i *Index) GetFindInIds(idx int, bufName, name string) string

func (*Index) GetFirstField

func (i *Index) GetFirstField() *Field

func (*Index) GetFuncParam

func (i *Index) GetFuncParam() string

func (*Index) GetFuncParamIn

func (i *Index) GetFuncParamIn() string

func (*Index) GetFuncParamNames

func (i *Index) GetFuncParamNames(prefixs ...string) string

func (*Index) GetFuncParamOriNames

func (i *Index) GetFuncParamOriNames() string

func (*Index) IsFindInType

func (i *Index) IsFindInType(field *Field) bool

func (*Index) MysqlCreation

func (i *Index) MysqlCreation(obj *Obj) string

type ListedField

type ListedField struct {
	Key      string
	ObjName  string
	ObjField string
}

type Obj

type Obj struct {
	Db           string
	Dbs          []string
	Extend       string
	Fields       []*Field
	FieldNameMap map[string]*Field
	FilterFields []string
	Indexes      []*Index
	Name         string
	Namespace    string
	// Package is deprecated , use Namespace instead
	Package     string
	GoPackage   string
	SearchIndex string
	SearchType  string
	Table       string
	TplWriter   io.Writer
	DbName      string
	StoreType   string
	ValueType   string
	ValueField  *Field
	ModelType   string
	ImportSQL   string
	Comment     string

	// IsEmbed describes whether the object should embedded in another object.
	// The embedded object will not generator the orm method but only the db struct.
	IsEmbed bool
}

func (*Obj) DbContains

func (o *Obj) DbContains(db string) bool

func (*Obj) DbSwitch

func (o *Obj) DbSwitch(db string) bool

! for the multiple dbs support struct template switch

func (*Obj) FieldsMap

func (o *Obj) FieldsMap() map[string]generator.IField

func (*Obj) GetAllNamesAsArgs

func (o *Obj) GetAllNamesAsArgs(prefix string) []string

func (*Obj) GetByFields

func (o *Obj) GetByFields(f []*Field) []string

func (*Obj) GetConfigTemplates

func (o *Obj) GetConfigTemplates() []string

func (*Obj) GetFieldNameWithDB

func (o *Obj) GetFieldNameWithDB(name string) string

func (*Obj) GetFieldNames

func (o *Obj) GetFieldNames() []string

func (*Obj) GetFieldNamesAsArgs

func (o *Obj) GetFieldNamesAsArgs(prefix string) []string

func (*Obj) GetFilterFields

func (o *Obj) GetFilterFields() []*Field

func (*Obj) GetForeignKeys

func (o *Obj) GetForeignKeys() []*Field

func (*Obj) GetFormImports

func (o *Obj) GetFormImports() (imports []string)

func (*Obj) GetGenTypes

func (o *Obj) GetGenTypes() []string

func (*Obj) GetListedFields

func (o *Obj) GetListedFields() []*ListedField

func (*Obj) GetNonIDFields

func (o *Obj) GetNonIDFields() []*Field

func (*Obj) GetNonIdFieldNames

func (o *Obj) GetNonIdFieldNames() []string

func (*Obj) GetOrmImports

func (o *Obj) GetOrmImports() (imports []string)

func (*Obj) GetPrimaryKey

func (o *Obj) GetPrimaryKey() *Field

func (*Obj) GetPrimaryKeyName

func (o *Obj) GetPrimaryKeyName() string

func (*Obj) GetStringFilterFields

func (o *Obj) GetStringFilterFields() []*Field

func (*Obj) GetTable

func (o *Obj) GetTable() string

func (*Obj) GetTimeFields

func (o *Obj) GetTimeFields() []*Field

func (*Obj) HasTimeFields

func (o *Obj) HasTimeFields() bool

func (*Obj) LoadField

func (o *Obj) LoadField(f *Field) string

func (*Obj) LoadTpl

func (o *Obj) LoadTpl(tpl string) string

func (*Obj) NeedIndex

func (o *Obj) NeedIndex() bool

func (*Obj) NeedMapping

func (o *Obj) NeedMapping() bool

func (*Obj) NeedOrm

func (o *Obj) NeedOrm() bool

func (*Obj) NeedSearch

func (o *Obj) NeedSearch() bool

func (*Obj) Read

func (o *Obj) Read(name string, data generator.Schema) error

type Transform

type Transform struct {
	TypeOrigin  string
	ConvertTo   string
	TypeTarget  string
	ConvertBack string
}

Jump to

Keyboard shortcuts

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