parser

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

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 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     orm.Set
	Attrs     map[string]string
	Comment   string
	Validator string
	Obj       *MetaObject
	ESIndex   ESIndex
	// 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) 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) 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) 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) 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 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) GetRelation

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

func (*Index) HasPrimaryKey

func (idx *Index) HasPrimaryKey() 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
	// contains filtered or unexported fields
}

func NewMetaObject

func NewMetaObject(packageName string) *MetaObject

func ReadYaml

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

func (*MetaObject) Comment

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) 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 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) 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