parser

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2021 License: Apache-2.0 Imports: 10 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ESAnalyzableFields = map[string]bool{
	"string": true,
}
View Source
var SupportedESFieldTypes = map[string]string{
	"bool":      "boolean",
	"int":       "integer",
	"int8":      "byte",
	"int16":     "short",
	"int32":     "integer",
	"int64":     "long",
	"float32":   "float",
	"float64":   "double",
	"string":    "string",
	"datetime":  "date",
	"timestamp": "date",
	"timeint":   "long",
}
View Source
var SupportedFieldTypes = map[string]string{
	"bool":      "bool",
	"int":       "int32",
	"int8":      "int8",
	"int16":     "int16",
	"int32":     "int32",
	"int64":     "int64",
	"uint":      "uint32",
	"uint8":     "uint8",
	"uint16":    "uint16",
	"uint32":    "uint32",
	"uint64":    "uint64",
	"float32":   "float32",
	"float64":   "float64",
	"string":    "string",
	"datetime":  "datetime",
	"timestamp": "timestamp",
	"timeint":   "timeint",
}

Functions

func Camel2Name

func Camel2Name(s string) string

//////////////////////////////////////////////////////////////////////

func CamelName added in v1.5.0

func CamelName(argName string) string

func ToIds

func ToIds(bufName, typeName, name string) string

Types

type ESIndex

type ESIndex struct {
	Type       string
	DoIndex    bool
	DateFormat string
	DoAnalyze  bool
	Analyzer   string
}

func (*ESIndex) IndexType

func (e *ESIndex) IndexType() string

func (*ESIndex) SetType

func (e *ESIndex) SetType(t string) error

func (*ESIndex) ShouldAnalyze

func (e *ESIndex) ShouldAnalyze() bool

func (*ESIndex) ShouldIndex

func (e *ESIndex) ShouldIndex() bool

func (*ESIndex) TplMappingSettings

func (e *ESIndex) TplMappingSettings() []TplESIndexMappingField

type Field

type Field struct {
	Name string
	Type string

	Size      int
	Flags     set.Set
	Attrs     map[string]string
	Comment   string
	Validator string
	Obj       *MetaObject
	ESIndex   ESIndex
	Default   interface{}
	PBField   *PBField
	// contains filtered or unexported fields
}

func NewField

func NewField() *Field

func (*Field) ColumnName

func (f *Field) ColumnName() string

func (*Field) FieldName

func (f *Field) FieldName() string

func (*Field) GetNames added in v1.5.0

func (f *Field) GetNames() string

func (*Field) GetNullSQLType

func (f *Field) GetNullSQLType() string

func (*Field) GetTag

func (f *Field) GetTag() string

func (*Field) GetTransform

func (f *Field) GetTransform() *Transform

func (*Field) GetTransformValue

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

func (*Field) GetType

func (f *Field) GetType() string

func (*Field) HasIndex

func (f *Field) HasIndex() bool

func (*Field) IsAutoIncrement

func (f *Field) IsAutoIncrement() bool

func (*Field) IsBool added in v1.5.0

func (f *Field) IsBool() bool

func (*Field) IsEncode

func (f *Field) IsEncode() bool

func (*Field) IsFullText

func (f *Field) IsFullText() bool

func (*Field) IsIndex

func (f *Field) IsIndex() bool

func (*Field) IsNeedTransform

func (f *Field) IsNeedTransform() bool

func (*Field) IsNorange added in v1.5.0

func (f *Field) IsNorange() bool

func (*Field) IsNullable

func (f *Field) IsNullable() bool

func (*Field) IsNullablePrimitive

func (f *Field) IsNullablePrimitive() bool

func (*Field) IsNumber

func (f *Field) IsNumber() bool

func (*Field) IsPrimary

func (f *Field) IsPrimary() bool

func (*Field) IsRange

func (f *Field) IsRange() bool

func (*Field) IsSetPBMapping added in v1.5.0

func (f *Field) IsSetPBMapping() bool

func (*Field) IsString

func (f *Field) IsString() bool

func (*Field) IsTime

func (f *Field) IsTime() bool

func (*Field) IsUnique

func (f *Field) IsUnique() bool

func (*Field) NullSQLTypeNeedCast

func (f *Field) NullSQLTypeNeedCast() bool

func (*Field) NullSQLTypeValue

func (f *Field) NullSQLTypeValue() string

func (*Field) Read

func (f *Field) Read(data map[interface{}]interface{}) error

func (*Field) SQLColumn

func (f *Field) SQLColumn(driver string) string

! field SQL script functions

func (*Field) SQLDefault

func (f *Field) SQLDefault(driver string) string

func (*Field) SQLName

func (f *Field) SQLName(driver string) string

func (*Field) SQLNull

func (f *Field) SQLNull(driver string) string

func (*Field) SQLType

func (f *Field) SQLType(driver string) string

func (*Field) SetType

func (f *Field) SetType(t string) error

type Fields added in v1.5.0

type Fields []*Field

func (Fields) GetConstructor added in v1.5.0

func (fs Fields) GetConstructor() string

func (Fields) GetFuncParam added in v1.5.0

func (fs Fields) GetFuncParam() string

func (Fields) GetObjectParam added in v1.5.0

func (fs Fields) GetObjectParam() string

type Index

type Index struct {
	Name       string
	Fields     []*Field
	FieldNames []string

	Obj *MetaObject
	// contains filtered or unexported fields
}

func NewIndex

func NewIndex(obj *MetaObject) *Index

func (*Index) FirstField added in v1.5.0

func (idx *Index) FirstField() *Field

func (*Index) GetConstructor added in v1.5.0

func (idx *Index) GetConstructor() string

func (*Index) GetFuncName added in v1.5.0

func (idx *Index) GetFuncName() string

func (*Index) GetFuncParam added in v1.5.0

func (idx *Index) GetFuncParam() string

func (*Index) GetRelation

func (idx *Index) GetRelation(storetype, valuetype, modeltype string) *Relation

func (*Index) HasPrimaryKey

func (idx *Index) HasPrimaryKey() bool

func (*Index) IsSingleField added in v1.5.0

func (idx *Index) IsSingleField() bool

func (*Index) LastField

func (idx *Index) LastField() *Field

type IndexArray

type IndexArray []*Index

func (IndexArray) Len

func (a IndexArray) Len() int

func (IndexArray) Less

func (a IndexArray) Less(i, j int) bool

func (IndexArray) Swap

func (a IndexArray) Swap(i, j int)

type MetaObject

type MetaObject struct {
	//! package name
	Package   string
	GoPackage string
	//! model name
	Name string
	Tag  string
	//! dbs
	Db  string
	Dbs []string

	//! database
	DbName  string
	DbTable string
	DbView  string

	//! relation
	Relation *Relation
	//! importSQL
	ImportSQL string
	//! elastic
	ElasticIndexAll bool
	// PB defines extra pb plugin
	PB *PBPlugin
	// contains filtered or unexported fields
}

func NewMetaObject

func NewMetaObject(packageName string) *MetaObject

func ReadYaml

func ReadYaml(packageName string, yamlFile string) ([]*MetaObject, error)

func (*MetaObject) CanSync added in v1.5.0

func (o *MetaObject) CanSync() bool

func (*MetaObject) Comment added in v1.0.4

func (m *MetaObject) Comment() string

func (*MetaObject) DbContains

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

func (*MetaObject) DbSource

func (o *MetaObject) DbSource() string

func (*MetaObject) ElasticIndexTypeName

func (m *MetaObject) ElasticIndexTypeName() string

func (*MetaObject) FieldByName

func (o *MetaObject) FieldByName(name string) *Field

func (*MetaObject) Fields

func (o *MetaObject) Fields() []*Field

func (*MetaObject) FromDB

func (o *MetaObject) FromDB() string

func (*MetaObject) Indexes

func (o *MetaObject) Indexes() []*Index

func (*MetaObject) IsPBValid added in v1.5.0

func (m *MetaObject) IsPBValid() bool

func (*MetaObject) LastField

func (o *MetaObject) LastField() *Field

func (*MetaObject) NoneIncrementFields

func (o *MetaObject) NoneIncrementFields() []*Field

func (*MetaObject) PrimaryField

func (o *MetaObject) PrimaryField() *Field

func (*MetaObject) PrimaryKey

func (o *MetaObject) PrimaryKey() *PrimaryKey

func (*MetaObject) Ranges

func (o *MetaObject) Ranges() []*Index

func (*MetaObject) Read

func (o *MetaObject) Read(name string, data map[string]interface{}) error

func (*MetaObject) Uniques

func (o *MetaObject) Uniques() []*Index

type PBField added in v1.5.0

type PBField struct {
	Name string
	Type string
}

type PBPlugin added in v1.5.0

type PBPlugin struct {
	ImportPath string
	Package    string
	Structs    []string
}

type PrimaryKey

type PrimaryKey struct {
	Name       string
	FieldNames []string
	Fields     []*Field
	Obj        *MetaObject
}

func NewPrimaryKey

func NewPrimaryKey(obj *MetaObject) *PrimaryKey

func (*PrimaryKey) FirstField

func (pk *PrimaryKey) FirstField() *Field

func (*PrimaryKey) GetConstructor added in v1.5.0

func (pk *PrimaryKey) GetConstructor() string

func (*PrimaryKey) GetFuncParam added in v1.5.0

func (pk *PrimaryKey) GetFuncParam() string

func (*PrimaryKey) GetObjectParam added in v1.5.0

func (pk *PrimaryKey) GetObjectParam() string

func (*PrimaryKey) IsAutocrement

func (pk *PrimaryKey) IsAutocrement() bool

func (*PrimaryKey) IsRange

func (pk *PrimaryKey) IsRange() bool

func (*PrimaryKey) IsSingleField

func (pk *PrimaryKey) IsSingleField() bool

func (*PrimaryKey) SQLColumn

func (pk *PrimaryKey) SQLColumn(driver string) string

type Relation

type Relation struct {
	Name      string
	StoreType string
	ValueType string
	ModelType string

	ValueField *Field

	//! owner
	Obj *MetaObject
	// contains filtered or unexported fields
}

func NewRelation

func NewRelation(obj *MetaObject) *Relation

func (*Relation) DB

func (r *Relation) DB() string

func (*Relation) Fields

func (r *Relation) Fields() []*Field

func (*Relation) NoneIncrementFields

func (r *Relation) NoneIncrementFields() []*Field

func (*Relation) PrimaryField

func (r *Relation) PrimaryField() *Field

func (*Relation) PrimaryKey

func (r *Relation) PrimaryKey() *PrimaryKey

func (*Relation) Read

func (r *Relation) Read(data map[interface{}]interface{}) error

type TplESIndexMappingField

type TplESIndexMappingField struct {
	Field string
	Value string
}

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