model

package
v0.0.0-...-04cb942 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildFederatedModel

func BuildFederatedModel(m *Model) error

BuildFederatedModel ...

func EnrichModel

func EnrichModel(m *Model) error

EnrichModel ...

func EnrichModelObjects

func EnrichModelObjects(m *Model) error

EnrichModelObjects ...

func PrintSchema

func PrintSchema(model Model) (string, error)

PrintSchema prints schema

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"`
}

Config struct

func LoadConfig

func LoadConfig() (c Config, err error)

LoadConfig loads config from path

func LoadConfigFromPath

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

LoadConfigFromPath ...

func (*Config) ConnMaxLifetime

func (c *Config) ConnMaxLifetime() float64

ConnMaxLifetime ...

func (*Config) MaxIdleConnections

func (c *Config) MaxIdleConnections() uint

MaxIdleConnections ...

func (*Config) MaxOpenConnections

func (c *Config) MaxOpenConnections() uint

MaxOpenConnections ...

type FilterMappingItem

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

FilterMappingItem ...

func (*FilterMappingItem) SuffixCamel

func (f *FilterMappingItem) SuffixCamel() string

SuffixCamel ...

func (*FilterMappingItem) WrapValueVariable

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

WrapValueVariable ...

type Model

type Model struct {
	Doc *ast.Document
}

Model ...

func Parse

func Parse(m string) (Model, error)

Parse ...

func (*Model) EmbeddedObjects

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

EmbeddedObjects ...

func (*Model) HasEnum

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

HasEnum ...

func (*Model) HasFederatedTypes

func (m *Model) HasFederatedTypes() bool

HasFederatedTypes ...

func (*Model) HasObject

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

HasObject ...

func (*Model) HasObjectExtension

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

HasObjectExtension ...

func (*Model) HasScalar

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

HasScalar ...

func (*Model) Object

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

Object ...

func (*Model) ObjectEntities

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

ObjectEntities ...

func (*Model) ObjectExtension

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

ObjectExtension ...

func (*Model) ObjectExtensions

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

ObjectExtensions ...

func (*Model) Objects

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

Objects ...

func (*Model) RemoveObjectExtension

func (m *Model) RemoveObjectExtension(oe *ObjectExtension)

RemoveObjectExtension ...

type Object

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

Object ...

func (*Object) AggregationsByField

func (o *Object) AggregationsByField() (res map[string]*ObjectFieldAggregation)

AggregationsByField ...

func (*Object) Column

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

Column ...

func (*Object) Columns

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

Columns ...

func (*Object) Directive

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

Directive ...

func (*Object) Field

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

Field ...

func (*Object) Fields

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

Fields ...

func (*Object) HasAggregableColumn

func (o *Object) HasAggregableColumn() bool

HasAggregableColumn ...

func (*Object) HasAnyRelationships

func (o *Object) HasAnyRelationships() bool

HasAnyRelationships ...

func (*Object) HasColumn

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

HasColumn ...

func (*Object) HasDirective

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

HasDirective ...

func (*Object) HasEmbeddedField

func (o *Object) HasEmbeddedField() bool

HasEmbeddedField ...

func (*Object) HasField

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

HasField ...

func (*Object) HasPreloadableRelationships

func (o *Object) HasPreloadableRelationships() bool

HasPreloadableRelationships ...

func (*Object) HasReadonlyColumns

func (o *Object) HasReadonlyColumns() bool

HasReadonlyColumns ...

func (*Object) HasRelationship

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

HasRelationship ...

func (*Object) Interfaces

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

Interfaces ...

func (*Object) IsExtended

func (o *Object) IsExtended() bool

IsExtended ...

func (*Object) IsFederatedType

func (o *Object) IsFederatedType() bool

IsFederatedType ...

func (*Object) IsToManyColumn

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

IsToManyColumn ...

func (*Object) LowerName

func (o *Object) LowerName() string

LowerName ...

func (*Object) Name

func (o *Object) Name() string

Name ...

func (*Object) NeedsQueryResolver

func (o *Object) NeedsQueryResolver() bool

NeedsQueryResolver ...

func (*Object) PluralName

func (o *Object) PluralName() string

PluralName ...

func (*Object) PreloadableRelationships

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

PreloadableRelationships ...

func (*Object) Relationship

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

Relationship ...

func (*Object) Relationships

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

Relationships ...

func (*Object) TableName

func (o *Object) TableName() string

TableName snake_case tablename

func (*Object) TableNameCC

func (o *Object) TableNameCC() string

TableNameCC camelCase tableName

func (*Object) TableNameLCC

func (o *Object) TableNameLCC() string

TableNameLCC lower camelCase tableName

type ObjectExtension

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

ObjectExtension ...

func (*ObjectExtension) ExtendsLocalObject

func (oe *ObjectExtension) ExtendsLocalObject() bool

ExtendsLocalObject ...

func (*ObjectExtension) HasAnyNonExternalField

func (oe *ObjectExtension) HasAnyNonExternalField() bool

HasAnyNonExternalField ...

func (*ObjectExtension) IsFederatedType

func (oe *ObjectExtension) IsFederatedType() bool

IsFederatedType ...

type ObjectField

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

ObjectField ...

func (*ObjectField) Aggregations

func (o *ObjectField) Aggregations() []ObjectFieldAggregation

Aggregations method

func (*ObjectField) ColumnType

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

ColumnType ...

func (*ObjectField) Directive

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

Directive ...

func (*ObjectField) FilterMapping

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

FilterMapping ...

func (*ObjectField) GoResultType

func (o *ObjectField) GoResultType() string

GoResultType ...

func (*ObjectField) GoType

func (o *ObjectField) GoType() string

GoType ...

func (*ObjectField) GoTypeWithPointer

func (o *ObjectField) GoTypeWithPointer(showPointer, ignoreEmbedded bool) string

GoTypeWithPointer ...

func (*ObjectField) HasDirective

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

HasDirective ...

func (*ObjectField) HasTargetObject

func (o *ObjectField) HasTargetObject() bool

HasTargetObject ...

func (*ObjectField) HasTargetObjectExtension

func (o *ObjectField) HasTargetObjectExtension() bool

HasTargetObjectExtension ...

func (*ObjectField) HasTargetTypeWithIDField

func (o *ObjectField) HasTargetTypeWithIDField() bool

HasTargetTypeWithIDField ...

func (*ObjectField) InputType

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

InputType ...

func (*ObjectField) InputTypeName

func (o *ObjectField) InputTypeName() string

InputTypeName ...

func (*ObjectField) IsAggregable

func (o *ObjectField) IsAggregable() bool

IsAggregable ...

func (*ObjectField) IsColumn

func (o *ObjectField) IsColumn() bool

IsColumn ...

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

func (o *ObjectField) IsExternal() bool

IsExternal ...

func (*ObjectField) IsFilterable

func (o *ObjectField) IsFilterable() bool

IsFilterable ...

func (*ObjectField) IsIdentifier

func (o *ObjectField) IsIdentifier() bool

IsIdentifier ...

func (*ObjectField) IsList

func (o *ObjectField) IsList() bool

IsList ...

func (*ObjectField) IsNumeric

func (o *ObjectField) IsNumeric() bool

IsNumeric ...

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

IsRelationship ...

func (*ObjectField) IsRelationshipIdentifier

func (o *ObjectField) IsRelationshipIdentifier() bool

IsRelationshipIdentifier ...

func (*ObjectField) IsScalarType

func (o *ObjectField) IsScalarType() bool

IsScalarType ...

func (*ObjectField) IsSearchable

func (o *ObjectField) IsSearchable() bool

IsSearchable ...

func (*ObjectField) IsSortable

func (o *ObjectField) IsSortable() bool

IsSortable ...

func (*ObjectField) IsString

func (o *ObjectField) IsString() bool

IsString ...

func (*ObjectField) IsUpdatable

func (o *ObjectField) IsUpdatable() bool

IsUpdatable ...

func (*ObjectField) IsWritableType

func (o *ObjectField) IsWritableType() bool

IsWritableType ...

func (*ObjectField) MethodName

func (o *ObjectField) MethodName() string

MethodName ...

func (*ObjectField) ModelTags

func (o *ObjectField) ModelTags() string

ModelTags ...

func (*ObjectField) Name

func (o *ObjectField) Name() string

Name ...

func (*ObjectField) NeedsQueryResolver

func (o *ObjectField) NeedsQueryResolver() bool

NeedsQueryResolver ...

func (*ObjectField) TargetObject

func (o *ObjectField) TargetObject() *Object

TargetObject ...

func (*ObjectField) TargetObjectExtension

func (o *ObjectField) TargetObjectExtension() *ObjectExtension

TargetObjectExtension ...

func (*ObjectField) TargetType

func (o *ObjectField) TargetType() string

TargetType ...

type ObjectFieldAggregation

type ObjectFieldAggregation struct {
	Field string
	Name  string
	Type  ast.Type
}

ObjectFieldAggregation specifies which aggregation functions are supported for given field

func (*ObjectFieldAggregation) FieldName

func (a *ObjectFieldAggregation) FieldName() string

FieldName ...

func (*ObjectFieldAggregation) SQLColumn

func (a *ObjectFieldAggregation) SQLColumn() string

SQLColumn ...

type ObjectRelationship

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

ObjectRelationship struct

func (*ObjectRelationship) BoolForRelationshipDirectiveAttribute

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

BoolForRelationshipDirectiveAttribute ...

func (*ObjectRelationship) ChangesName

func (o *ObjectRelationship) ChangesName() string

ChangesName ...

func (*ObjectRelationship) ChangesType

func (o *ObjectRelationship) ChangesType() string

ChangesType ...

func (*ObjectRelationship) ForeignKeyDestinationColumn

func (o *ObjectRelationship) ForeignKeyDestinationColumn() string

ForeignKeyDestinationColumn ...

func (*ObjectRelationship) ForeignKeyDestinationColumnCC

func (o *ObjectRelationship) ForeignKeyDestinationColumnCC() string

ForeignKeyDestinationColumnCC ...

func (*ObjectRelationship) GoType

func (o *ObjectRelationship) GoType() string

GoType ...

func (*ObjectRelationship) InverseRelationship

func (o *ObjectRelationship) InverseRelationship() *ObjectRelationship

InverseRelationship ...

func (*ObjectRelationship) InverseRelationshipName

func (o *ObjectRelationship) InverseRelationshipName() string

InverseRelationshipName ...

func (*ObjectRelationship) IsMainRelationshipForManyToMany

func (o *ObjectRelationship) IsMainRelationshipForManyToMany() bool

IsMainRelationshipForManyToMany ...

func (*ObjectRelationship) IsManyToMany

func (o *ObjectRelationship) IsManyToMany() bool

IsManyToMany ...

func (*ObjectRelationship) IsManyToOne

func (o *ObjectRelationship) IsManyToOne() bool

IsManyToOne ...

func (*ObjectRelationship) IsNonNull

func (o *ObjectRelationship) IsNonNull() bool

IsNonNull ...

func (*ObjectRelationship) IsOneToMany

func (o *ObjectRelationship) IsOneToMany() bool

IsOneToMany ...

func (*ObjectRelationship) IsSelfReferencing

func (o *ObjectRelationship) IsSelfReferencing() bool

IsSelfReferencing ...

func (*ObjectRelationship) IsToMany

func (o *ObjectRelationship) IsToMany() bool

IsToMany ...

func (*ObjectRelationship) IsToOne

func (o *ObjectRelationship) IsToOne() bool

IsToOne ...

func (*ObjectRelationship) JoinString

func (o *ObjectRelationship) JoinString() string

JoinString ...

func (*ObjectRelationship) MainRelationshipForManyToMany

func (o *ObjectRelationship) MainRelationshipForManyToMany() *ObjectRelationship

MainRelationshipForManyToMany ...

func (*ObjectRelationship) ManyToManyJoinTable

func (o *ObjectRelationship) ManyToManyJoinTable() string

ManyToManyJoinTable ...

func (*ObjectRelationship) ManyToManyObjectName

func (o *ObjectRelationship) ManyToManyObjectName() string

ManyToManyObjectName ...

func (*ObjectRelationship) ManyToManyObjectNameCC

func (o *ObjectRelationship) ManyToManyObjectNameCC() string

ManyToManyObjectNameCC ...

func (*ObjectRelationship) MethodName

func (o *ObjectRelationship) MethodName() string

MethodName ...

func (*ObjectRelationship) ModelTags

func (o *ObjectRelationship) ModelTags() string

ModelTags ...

func (*ObjectRelationship) Name

func (o *ObjectRelationship) Name() string

Name ...

func (*ObjectRelationship) OnDelete

func (o *ObjectRelationship) OnDelete(def string) string

OnDelete ...

func (*ObjectRelationship) OnUpdate

func (o *ObjectRelationship) OnUpdate(def string) string

OnUpdate ...

func (*ObjectRelationship) Preload

func (o *ObjectRelationship) Preload() bool

Preload ...

func (*ObjectRelationship) ReturnType

func (o *ObjectRelationship) ReturnType() string

ReturnType ...

func (*ObjectRelationship) StringForRelationshipDirectiveAttribute

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

StringForRelationshipDirectiveAttribute ...

func (*ObjectRelationship) Target

func (o *ObjectRelationship) Target() *Object

Target ...

func (*ObjectRelationship) TargetType

func (o *ObjectRelationship) TargetType() string

TargetType ...

func (*ObjectRelationship) ValueForRelationshipDirectiveAttribute

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

ValueForRelationshipDirectiveAttribute ...

Jump to

Keyboard shortcuts

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