model

package
v0.0.0-...-87ea0c4 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CREATE string = "Create"
	UPDATE string = "Update"
)

Variables

This section is empty.

Functions

func EnrichModel

func EnrichModel(m *Model) error

EnrichModel ...

func EnrichModelObjects

func EnrichModelObjects(m *Model) error

EnrichModelObjects ...

func GetRandomString

func GetRandomString(n int) string

func IndexOf

func IndexOf(str []interface{}, data interface{}) int

查找数组并返回下标

func PrintSchema

func PrintSchema(model Model) (string, error)

PrintSchema

func RegexpReplace

func RegexpReplace(str, start string, end string) string

正则截取

Types

type Config

type Config struct {
	Package    string `json:"package"`
	Connection *struct {
		MaxIdleConnections *uint   `json:"maxIdleConnections"`
		ConnMaxLifetime    *string `json:"connMaxLifetime"`
		MaxOpenConnections *uint   `json:"maxOpenConnections"`
	} `json:"connection,omitempty"`
}

func LoadConfig

func LoadConfig() (c Config, err error)

func LoadConfigFromPath

func LoadConfigFromPath(p string) (c Config, err error)

func (*Config) ConnMaxLifetime

func (c *Config) ConnMaxLifetime() float64

func (*Config) MaxIdleConnections

func (c *Config) MaxIdleConnections() uint

func (*Config) MaxOpenConnections

func (c *Config) MaxOpenConnections() uint

type FilterMappingItem

type FilterMappingItem struct {
	Suffix      string
	Operator    string
	InputType   ast.Type
	ValueFormat string
}

func (*FilterMappingItem) IsLike

func (f *FilterMappingItem) IsLike() bool

func (*FilterMappingItem) SuffixCamel

func (f *FilterMappingItem) SuffixCamel() string

func (*FilterMappingItem) WrapValueVariable

func (f *FilterMappingItem) WrapValueVariable(v string) string

type Model

type Model struct {
	Doc *ast.Document
}

func Parse

func Parse(m string) (Model, error)

Parse

func (*Model) HasEnum

func (m *Model) HasEnum(name string) bool

func (*Model) HasFederatedTypes

func (m *Model) HasFederatedTypes() bool

func (*Model) HasObject

func (m *Model) HasObject(name string) bool

func (*Model) HasObjectExtension

func (m *Model) HasObjectExtension(name string) bool

func (*Model) HasScalar

func (m *Model) HasScalar(name string) bool

func (*Model) Object

func (m *Model) Object(name string) Object

func (*Model) ObjectEntities

func (m *Model) ObjectEntities() []Object

func (*Model) ObjectExtension

func (m *Model) ObjectExtension(name string) ObjectExtension

func (*Model) ObjectExtensions

func (m *Model) ObjectExtensions() []ObjectExtension

func (*Model) Objects

func (m *Model) Objects() []Object

func (*Model) SecretKey

func (m *Model) SecretKey() string

type Object

type Object struct {
	Def       *ast.ObjectDefinition
	Model     *Model
	Extension *ObjectExtension
}

func (*Object) Column

func (o *Object) Column(name string) *ObjectField

func (*Object) Columns

func (o *Object) Columns() []ObjectField

Columns ...

func (*Object) Directive

func (o *Object) Directive(name string) *ast.Directive

func (*Object) EntityName

func (o *Object) EntityName() string

func (*Object) Field

func (o *Object) Field(name string) *ObjectField

func (*Object) Fields

func (o *Object) Fields() []ObjectField

Fields ...

func (*Object) HasAnyRelationships

func (o *Object) HasAnyRelationships() bool

func (*Object) HasColumn

func (o *Object) HasColumn(name string) bool

func (*Object) HasDirective

func (o *Object) HasDirective(name string) bool

func (*Object) HasEmbeddedField

func (o *Object) HasEmbeddedField() bool

func (*Object) HasField

func (o *Object) HasField(name string) bool

func (*Object) HasPreloadableRelationships

func (o *Object) HasPreloadableRelationships() bool

func (*Object) HasRelationship

func (o *Object) HasRelationship(name string) bool

func (*Object) Interfaces

func (o *Object) Interfaces() []string

func (*Object) IsExtended

func (o *Object) IsExtended() bool

func (*Object) IsFederatedType

func (o *Object) IsFederatedType() bool

func (*Object) IsToManyColumn

func (o *Object) IsToManyColumn(c ObjectField) bool

func (*Object) LowerName

func (o *Object) LowerName() string

func (*Object) Name

func (o *Object) Name() string

Name ...

func (*Object) NeedsQueryResolver

func (o *Object) NeedsQueryResolver() bool

func (*Object) PluralName

func (o *Object) PluralName() string

func (*Object) PreloadableRelationships

func (o *Object) PreloadableRelationships() []*ObjectRelationship

func (*Object) Relationship

func (o *Object) Relationship(name string) *ObjectRelationship

func (*Object) Relationships

func (o *Object) Relationships() []*ObjectRelationship

func (*Object) TableName

func (o *Object) TableName() string

func (*Object) ToCamel

func (o *Object) ToCamel() string

func (*Object) ToLowerPluralName

func (o *Object) ToLowerPluralName() string

func (*Object) ToSnakeName

func (o *Object) ToSnakeName() string

func (*Object) ToSnakePluraName

func (o *Object) ToSnakePluraName() string

type ObjectExtension

type ObjectExtension struct {
	Def    *ast.TypeExtensionDefinition
	Model  *Model
	Object *Object
}

func (*ObjectExtension) ExtendsLocalObject

func (oe *ObjectExtension) ExtendsLocalObject() bool

func (*ObjectExtension) IsFederatedType

func (oe *ObjectExtension) IsFederatedType() bool

type ObjectField

type ObjectField struct {
	Def *ast.FieldDefinition
	Obj *Object
}

func (*ObjectField) Arguments

func (o *ObjectField) Arguments() string

获取Arguments

func (*ObjectField) ArgumentsValue

func (o *ObjectField) ArgumentsValue() []ObjectFieldInput

func (*ObjectField) ColumnType

func (o *ObjectField) ColumnType() (value string)

ColumnType ...

func (*ObjectField) Directive

func (o *ObjectField) Directive(name string) *ast.Directive

func (*ObjectField) EntityName

func (o *ObjectField) EntityName() string

表名

func (*ObjectField) FilterMapping

func (o *ObjectField) FilterMapping() []FilterMappingItem

func (*ObjectField) GetArgValue

func (o *ObjectField) GetArgValue(name string) map[string]map[string]string

func (*ObjectField) GetComment

func (o *ObjectField) GetComment() string

获取字段说明

func (*ObjectField) GetDefault

func (o *ObjectField) GetDefault() string

获取是否默认显示

func (*ObjectField) GetRemark

func (o *ObjectField) GetRemark() string

备注说明字段

func (*ObjectField) GetTableName

func (o *ObjectField) GetTableName() string

获取是否默认显示

func (*ObjectField) GetType

func (o *ObjectField) GetType() string

获取字段说明

func (*ObjectField) GetValidator

func (o *ObjectField) GetValidator() string

获取正则验证

func (*ObjectField) GoType

func (o *ObjectField) GoType() string

func (*ObjectField) GoTypeWithPointer

func (o *ObjectField) GoTypeWithPointer() string

func (*ObjectField) HasDirective

func (o *ObjectField) HasDirective(name string) bool

func (*ObjectField) HasName

func (o *ObjectField) HasName(name string) bool

func (*ObjectField) HasTargetObject

func (o *ObjectField) HasTargetObject() bool

HasTargetObject ...

func (*ObjectField) HasTargetObjectExtension

func (o *ObjectField) HasTargetObjectExtension() bool

func (*ObjectField) HasTargetTypeWithIDField

func (o *ObjectField) HasTargetTypeWithIDField() bool

func (*ObjectField) InputType

func (o *ObjectField) InputType() ast.Type

InputType ...

func (*ObjectField) Inputs

func (o *ObjectField) Inputs() string

获取Input

func (*ObjectField) IsColumn

func (o *ObjectField) IsColumn() bool

func (*ObjectField) IsCreataDocs

func (o *ObjectField) IsCreataDocs() bool

func (*ObjectField) IsCreatable

func (o *ObjectField) IsCreatable() bool

IsCreatable ...

func (*ObjectField) IsEmbedded

func (o *ObjectField) IsEmbedded() bool

IsEmbedded ...

func (*ObjectField) IsEmbeddedColumn

func (o *ObjectField) IsEmbeddedColumn() bool

IsEmbeddedColumn ...

func (*ObjectField) IsEnumType

func (o *ObjectField) IsEnumType() bool

IsEnumType ...

func (*ObjectField) IsHasUpperId

func (o *ObjectField) IsHasUpperId() bool

func (*ObjectField) IsID

func (o *ObjectField) IsID() bool

func (*ObjectField) IsIdentifier

func (o *ObjectField) IsIdentifier() bool

IsIdentifier ...

func (*ObjectField) IsInt

func (o *ObjectField) IsInt() bool

func (*ObjectField) IsList

func (o *ObjectField) IsList() bool

IsList ...

func (*ObjectField) IsListType

func (o *ObjectField) IsListType() bool

func (*ObjectField) IsOptional

func (o *ObjectField) IsOptional() bool

IsOptional ...

func (*ObjectField) IsReadonlyType

func (o *ObjectField) IsReadonlyType() bool

IsReadonlyType ..

func (*ObjectField) IsRelationship

func (o *ObjectField) IsRelationship() bool

func (*ObjectField) IsRelationshipIdentifier

func (o *ObjectField) IsRelationshipIdentifier() bool

IsRelationshipIdentifier ...

func (*ObjectField) IsRelationshipRequired

func (o *ObjectField) IsRelationshipRequired() bool

func (*ObjectField) IsRequired

func (o *ObjectField) IsRequired() bool

func (*ObjectField) IsScalarType

func (o *ObjectField) IsScalarType() bool

IsScalarType ...

func (*ObjectField) IsSearchable

func (o *ObjectField) IsSearchable() bool

func (*ObjectField) IsSortable

func (o *ObjectField) IsSortable() bool

func (*ObjectField) IsString

func (o *ObjectField) IsString() bool

func (*ObjectField) IsUpdatable

func (o *ObjectField) IsUpdatable() bool

func (*ObjectField) IsWritableType

func (o *ObjectField) IsWritableType() bool

func (*ObjectField) LowerName

func (o *ObjectField) LowerName() string

func (*ObjectField) MethodName

func (o *ObjectField) MethodName() string

func (*ObjectField) ModelTags

func (o *ObjectField) ModelTags() string

func (*ObjectField) Name

func (o *ObjectField) Name() string

func (*ObjectField) NeedsQueryResolver

func (o *ObjectField) NeedsQueryResolver() bool

func (*ObjectField) RelationshipName

func (o *ObjectField) RelationshipName() string

func (*ObjectField) RelationshipTypeName

func (o *ObjectField) RelationshipTypeName() string

func (*ObjectField) TargetObject

func (o *ObjectField) TargetObject() *Object

func (*ObjectField) TargetObjectExtension

func (o *ObjectField) TargetObjectExtension() *ObjectExtension

func (*ObjectField) TargetType

func (o *ObjectField) TargetType() string

TargetType ...

func (*ObjectField) ToSnakeName

func (o *ObjectField) ToSnakeName() string

type ObjectFieldInput

type ObjectFieldInput struct {
	Def   *ast.InputValueDefinition
	Field *ObjectField
}

func (*ObjectFieldInput) IsListType

func (o *ObjectFieldInput) IsListType() bool

func (*ObjectFieldInput) Name

func (o *ObjectFieldInput) Name() string

func (*ObjectFieldInput) NonNullType

func (o *ObjectFieldInput) NonNullType() string

func (*ObjectFieldInput) Required

func (o *ObjectFieldInput) Required() bool

func (*ObjectFieldInput) TargetType

func (o *ObjectFieldInput) TargetType() string

type ObjectRelationship

type ObjectRelationship struct {
	Def *ast.FieldDefinition
	Obj *Object
}

func (*ObjectRelationship) BoolForRelationshipDirectiveAttribute

func (o *ObjectRelationship) BoolForRelationshipDirectiveAttribute(name string) (val bool, ok bool)

func (*ObjectRelationship) ChangesName

func (o *ObjectRelationship) ChangesName() string

func (*ObjectRelationship) ChangesType

func (o *ObjectRelationship) ChangesType() string

func (*ObjectRelationship) GoType

func (o *ObjectRelationship) GoType() string

func (*ObjectRelationship) InverseRelationship

func (o *ObjectRelationship) InverseRelationship() *ObjectRelationship

func (*ObjectRelationship) InverseRelationshipName

func (o *ObjectRelationship) InverseRelationshipName() string

func (*ObjectRelationship) IsDelete

func (o *ObjectRelationship) IsDelete() bool

func (*ObjectRelationship) IsMainRelationshipForManyToMany

func (o *ObjectRelationship) IsMainRelationshipForManyToMany() bool

func (*ObjectRelationship) IsManyToMany

func (o *ObjectRelationship) IsManyToMany() bool

func (*ObjectRelationship) IsManyToOne

func (o *ObjectRelationship) IsManyToOne() bool

func (*ObjectRelationship) IsMaster

func (o *ObjectRelationship) IsMaster() bool

func (*ObjectRelationship) IsNonNull

func (o *ObjectRelationship) IsNonNull() bool

func (*ObjectRelationship) IsOneToMany

func (o *ObjectRelationship) IsOneToMany() bool

func (*ObjectRelationship) IsSelfReferencing

func (o *ObjectRelationship) IsSelfReferencing() bool

func (*ObjectRelationship) IsToMany

func (o *ObjectRelationship) IsToMany() bool

func (*ObjectRelationship) IsToOne

func (o *ObjectRelationship) IsToOne() bool

func (*ObjectRelationship) JoinString

func (o *ObjectRelationship) JoinString() string

func (*ObjectRelationship) LowerName

func (o *ObjectRelationship) LowerName() string

func (*ObjectRelationship) MainRelationshipForManyToMany

func (o *ObjectRelationship) MainRelationshipForManyToMany() *ObjectRelationship

func (*ObjectRelationship) ManyToManyJoinTable

func (o *ObjectRelationship) ManyToManyJoinTable() string

func (*ObjectRelationship) MethodName

func (o *ObjectRelationship) MethodName() string

func (*ObjectRelationship) ModelTags

func (o *ObjectRelationship) ModelTags() string

func (*ObjectRelationship) Name

func (o *ObjectRelationship) Name() string

func (*ObjectRelationship) Preload

func (o *ObjectRelationship) Preload() bool

func (*ObjectRelationship) ReturnType

func (o *ObjectRelationship) ReturnType() string

func (*ObjectRelationship) StringForRelationshipDirectiveAttribute

func (o *ObjectRelationship) StringForRelationshipDirectiveAttribute(name string) (val string, ok bool)

func (*ObjectRelationship) Target

func (o *ObjectRelationship) Target() *Object

func (*ObjectRelationship) TargetType

func (o *ObjectRelationship) TargetType() string

func (*ObjectRelationship) ToSnakeName

func (o *ObjectRelationship) ToSnakeName() string

func (*ObjectRelationship) ToSnakeRelationshipName

func (o *ObjectRelationship) ToSnakeRelationshipName() string

func (*ObjectRelationship) UpperRelationshipName

func (o *ObjectRelationship) UpperRelationshipName() string

func (*ObjectRelationship) ValueForRelationshipDirectiveAttribute

func (o *ObjectRelationship) ValueForRelationshipDirectiveAttribute(name string) (val interface{}, ok bool)

Jump to

Keyboard shortcuts

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