Documentation ¶
Index ¶
- type BaseSchema
- type BaseSchemaField
- type Connection
- type CtxImports
- type CtxPkg
- type Environment
- func (env *Environment) AddBaseSchema(baseSchema *BaseSchema) *BaseSchema
- func (env *Environment) AddModel(model *Model) *Model
- func (env *Environment) AddQuery(query *Query) *Query
- func (env *Environment) AddSchema(schema *Schema) *Schema
- func (env *Environment) AddStore(store *Store) *Store
- func (env *Environment) EnsureConnection(name string) (*Connection, bool)
- type Field
- type Fieldable
- type FieldableContext
- type Model
- type ModelField
- type Query
- type QueryField
- type Relation
- type Schema
- type SchemaField
- type Store
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 Connection ¶
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 }
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 Fieldable ¶
type Fieldable struct { Name string TableName string Connection string IsModel bool IsEmbedded bool Fields []*Field FieldsByColumnMap map[string]*Field PK *Field }
func NewFieldable ¶
NewFieldable returns a new instance of `Fieldable` with the given `name` set.
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 (*Model) AddField ¶
func (model *Model) AddField(field *ModelField) *ModelField
func (*Model) AddRelation ¶
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 ¶
AddRelation appends the given `relation` to the relation list.
type QueryField ¶
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 ¶
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.