models

package
v0.0.0-...-d79b3d1 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseSchema

type BaseSchema struct {
	Name         string
	FullName     string
	TableName    string
	Fields       []*BaseSchemaField
	FieldsIdxMap map[string]int
	FieldsMap    map[string]*BaseSchemaField
	IsModel      bool
}

func NewBaseSchema

func NewBaseSchema(name, tableName string) *BaseSchema

func (*BaseSchema) AddField

func (schema *BaseSchema) AddField(name, columnName string, isPK, isAutoIncr bool) *BaseSchemaField

AddField adds a new instance of BaseSchemaField to the schema fields and returns it.

type BaseSchemaField

type BaseSchemaField struct {
	Name       string
	ColumnName string
	Type       string
	IsAutoIncr bool
	IsPK       bool
}

type Connection

type Connection struct {
	Name     string
	FullName string
}

func NewConnection

func NewConnection(name string) *Connection

NewConnection retrurns a new instance of `Connection` with the given `name` set.

type CtxImports

type CtxImports struct {
	Pkg     *myasthurts.Package
	Imports map[string]*CtxPkg
	// contains filtered or unexported fields
}

func NewCtxImports

func NewCtxImports(pkg *myasthurts.Package) *CtxImports

func (*CtxImports) AddImportPkg

func (ctx *CtxImports) AddImportPkg(pkg *myasthurts.Package) *CtxPkg

func (*CtxImports) AddRefType

func (ctx *CtxImports) AddRefType(refType myasthurts.RefType) *CtxPkg

func (*CtxImports) Ref

func (ctx *CtxImports) Ref(refType myasthurts.RefType) string

type CtxPkg

type CtxPkg struct {
	Pkg   *myasthurts.Package
	Alias string
}

func (*CtxPkg) Ref

func (ctxPkg *CtxPkg) Ref(pkg *myasthurts.Package, typeName string) string

type Environment

type Environment struct {
	InputPkg     *myasthurts.Package
	InputPkgCtx  *CtxPkg
	OutputPkg    *myasthurts.Package
	OutputPkgCtx *CtxPkg
	Queries      []*Query
	BaseSchemas  []*BaseSchema
	Schemas      []*Schema
	Stores       []*Store
	Connections  []*Connection

	Models        []*Model
	Imports       *CtxImports
	ModelsImports *CtxImports
	// contains filtered or unexported fields
}

Environment represents all set of information that should be used to generate the models complement, queries, stores, schemas and connections.

func NewEnvironment

func NewEnvironment(inputPkg, outputPkg *myasthurts.Package, imports *CtxImports, modelsImports *CtxImports) *Environment

NewEnvironment returns a new instance of an `Environment`.

func (*Environment) AddBaseSchema

func (env *Environment) AddBaseSchema(baseSchema *BaseSchema) *BaseSchema

AddBaseSchema adds a `BaseSchema` to the environment base schema list.

func (*Environment) AddModel

func (env *Environment) AddModel(model *Model) *Model

AddModel adds a `Model` to the environment model list.

func (*Environment) AddQuery

func (env *Environment) AddQuery(query *Query) *Query

AddQuery adds a `Query` to the environment query list.

func (*Environment) AddSchema

func (env *Environment) AddSchema(schema *Schema) *Schema

AddSchema adds a `Schema` to the environment schema list.

func (*Environment) AddStore

func (env *Environment) AddStore(store *Store) *Store

AddStore adds a `Store` to the environment store list.

func (*Environment) EnsureConnection

func (env *Environment) EnsureConnection(name string) (*Connection, bool)

EnsureConnection tries to find a Conection in the list, if it does not exists, the method will create one and return its reference.

type Field

type Field struct {
	Name             string
	FieldPath        string
	Column           string
	IsAutoIncrement  bool
	IsPrimaryKey     bool
	ForeignKeyColumn string
	Type             string
	RefType          myasthurts.RefType
	Fieldable        *Fieldable
}

func NewField

func NewField(name, fieldPath, column, foreignKeyColumn string, refType myasthurts.RefType) *Field

NewField returns a new instance of `Field` with the given `name`, `fieldPath`, `column` set.

type Fieldable

type Fieldable struct {
	Name              string
	TableName         string
	Connection        string
	IsModel           bool
	IsEmbedded        bool
	Fields            []*Field
	FieldsByColumnMap map[string]*Field
	PK                *Field
}

func NewFieldable

func NewFieldable(name string) *Fieldable

NewFieldable returns a new instance of `Fieldable` with the given `name` set.

func (*Fieldable) AddField

func (f *Fieldable) AddField(field *Field) *Field

AddField appends the field to the list of fields and returns it.

type FieldableContext

type FieldableContext struct {
	InputPkg      *myasthurts.Package
	Imports       *CtxImports
	ModelsImports *CtxImports
	Reporter      reporters.Reporter

	Fieldables   []*Fieldable
	FieldableMap map[string]*Fieldable
}

func NewFieldableContext

func NewFieldableContext(inputPkg, outputPkg *myasthurts.Package, reporter reporters.Reporter) *FieldableContext

func (*FieldableContext) EnsureFieldable

func (f *FieldableContext) EnsureFieldable(name string) *Fieldable

EnsureFieldable tries to get the `Fieldable` from the map, if it does not exists adds creates one, adding to the list and map.

type Model

type Model struct {
	Name      string
	PK        *ModelField
	Fields    []*ModelField
	Relations []*Relation
}

func NewModel

func NewModel(name string) *Model

func (*Model) AddField

func (model *Model) AddField(field *ModelField) *ModelField

func (*Model) AddRelation

func (model *Model) AddRelation(relation *Relation) *Relation

type ModelField

type ModelField struct {
	Name string
}

func NewModelField

func NewModelField(name string) *ModelField

type Query

type Query struct {
	Name       string
	FullName   string
	BaseSchema *BaseSchema
	Fields     []*QueryField
	Relations  []*Relation
}

func NewQuery

func NewQuery(baseSchema *BaseSchema, name string) *Query

NewQuery returns a new instance of `Query` with the given `name` set.

func (*Query) AddField

func (q *Query) AddField(field *QueryField) *QueryField

AddField appends the given `field` to the fields list.

func (*Query) AddRelation

func (q *Query) AddRelation(relation *Relation) *Relation

AddRelation appends the given `relation` to the relation list.

type QueryField

type QueryField struct {
	Name       string
	FieldPath  string
	MethodName string
	Type       string
}

func NewQueryField

func NewQueryField(name string, fieldPath []string) *QueryField

NewQueryField returns a new instance of `QueryField` with the given params set.

type Relation

type Relation struct {
	Query            *Query
	Name             string
	FullName         string
	LocalField       string
	LocalFieldRef    string
	LocalModelType   string
	LocalColumn      string
	ForeignField     string
	ForeignModelType string
	ForeignColumn    string
	ForeignFieldType string
}

func NewRelation

func NewRelation(query *Query, name, localField, localFieldRef, localModelType, localColumn, foreignModelType, foreignField, foreignColumn, foreignFieldType string) *Relation

type Schema

type Schema struct {
	IsModel    bool
	Name       string
	FullName   string
	BaseSchema *BaseSchema
	Fields     []*SchemaField
}

func NewSchema

func NewSchema(name string, baseSchema *BaseSchema) *Schema

func (*Schema) AddField

func (schema *Schema) AddField(name, t, schemaName, columnName string) *SchemaField

AddField adds a new instance of SchemaField to the schema fields and returns it.

type SchemaField

type SchemaField struct {
	Name       string
	Type       string
	SchemaName string
	ColumnName string
}

type Store

type Store struct {
	Name     string
	FullName string
	ModelRef string
}

func NewStore

func NewStore(name string) *Store

NewStore returns a new instance of a `Store` with a given `name`.

Jump to

Keyboard shortcuts

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