preformBuilder

package
v0.0.0-...-1e4cd2d Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: MIT Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ForeignKeyCnfSetters = foreignKeyCnf{}
	ReverseType          = allReverseType{ToMany: 0, ToOne: 1, NoReverse: 2}
)

Functions

func BuildCustomType

func BuildCustomType(modelPkgName, path string, customTypesBySchema map[string]map[string]*preformShare.CustomType)

func BuildDbMainFile

func BuildDbMainFile(modelPkgName, path string, queries []preformShare.IQueryBuilder, schemas ...string)

func BuildEnum

func BuildEnum(modelPkgName, path string, enumsBySchema map[string]map[string][]string)

func BuildModel

func BuildModel(conn *sql.DB, modelPkgName, outputFiles string, schemasEmptyIsAll ...string)

func BuildSchema

func BuildSchema(modelPkgName, path, defaultDbOrSchema, schemaCodeName string, factories []preformShare.IFactoryBuilder, enums map[string][]string, customTypes map[string]*preformShare.CustomType)

func FkComposite

func FkComposite(lk, fk preformShare.IColDef) foreignKeyCnfSetter

func FkCond

func FkCond(cond preformShare.ICondForBuilder, reverseCond ...preformShare.ICondForBuilder) foreignKeyCnfSetter

func FkMiddleTable

func FkMiddleTable(table preformShare.IFactoryBuilder, localKeys []preformShare.IColDef, mtLocalKey []preformShare.IColDef, foreignKeys []preformShare.IColDef, mtForeignKey []preformShare.IColDef) foreignKeyCnfSetter

func FkName

func FkName(name string) foreignKeyCnfSetter

func FkRelationName

func FkRelationName(name string) foreignKeyCnfSetter

func FkReverse

func FkReverse(r reverseType) foreignKeyCnfSetter

func FkReverseName

func FkReverseName(name string) foreignKeyCnfSetter

func FkToMany

func FkToMany() foreignKeyCnfSetter

func InitColBySchema

func InitColBySchema(col *preformShare.Column, builder iFactoryBuilder) iColDef

func InitFactoryBuilder

func InitFactoryBuilder[D iFactoryBuilder](schemaName string, setter func(D)) D

func PrepareSchema

func PrepareSchema(modelPkgName, path, defaultDbOrSchema, schemaCodeName string, factories []preformShare.IFactoryBuilder)

Types

type ColumnDef

type ColumnDef[T any] struct {
	// contains filtered or unexported fields
}

func (ColumnDef) Aggregate

func (a ColumnDef) Aggregate(fn preformShare.Aggregator, aggregatedType reflect.Type, params ...any) *aggregatedCol[T]

func (ColumnDef) Alias

func (c ColumnDef) Alias() string

func (ColumnDef) Avg

func (a ColumnDef) Avg() *aggregatedCol[T]

func (ColumnDef) CodeName

func (c ColumnDef) CodeName() string

func (ColumnDef[T]) ColDef

func (c ColumnDef[T]) ColDef() preformShare.IColDef

func (ColumnDef) Count

func (a ColumnDef) Count() *aggregatedCol[T]

func (ColumnDef) CountDistinct

func (a ColumnDef) CountDistinct() *aggregatedCol[T]

func (ColumnDef) Factory

func (c ColumnDef) Factory() preformShare.IFactoryBuilder

func (ColumnDef[T]) GenerateCode

func (c ColumnDef[T]) GenerateCode(schemaName string, fromQuery bool) (importPath []string, defColCode []string, modelColCode []string, settingCodes []string, extraFunc string)

func (ColumnDef[T]) GetType

func (c ColumnDef[T]) GetType() reflect.Type

func (ColumnDef) GroupConcat

func (a ColumnDef) GroupConcat(splitter string) *aggregatedCol[T]

func (*ColumnDef[T]) InitCol

func (c *ColumnDef[T]) InitCol(ref *reflect.StructField, builder iFactoryBuilder)

func (ColumnDef) Max

func (a ColumnDef) Max() *aggregatedCol[T]

func (ColumnDef) Mean

func (a ColumnDef) Mean() *aggregatedCol[T]

func (ColumnDef) Median

func (a ColumnDef) Median() *aggregatedCol[T]

func (ColumnDef) Min

func (a ColumnDef) Min() *aggregatedCol[T]

func (ColumnDef) Mode

func (a ColumnDef) Mode() *aggregatedCol[T]

func (ColumnDef) OColName

func (c ColumnDef) OColName() string

func (*ColumnDef[T]) OverwriteType

func (c *ColumnDef[T]) OverwriteType(col preformShare.IColDef) *ColumnDef[T]

OverwriteType

func (*ColumnDef[T]) PK

func (c *ColumnDef[T]) PK() *PrimaryKeyDef[T]

func (ColumnDef) RelatedFk

func (c ColumnDef) RelatedFk(def preformShare.IColDef) *columnDef[T]

func (ColumnDef) RelatedFks

func (c ColumnDef) RelatedFks() []preformShare.IColDef

func (*ColumnDef[T]) SetAlias

func (c *ColumnDef[T]) SetAlias(alias string) *ColumnDef[T]

func (ColumnDef[T]) SetAliasI

func (c ColumnDef[T]) SetAliasI(alias string) preformShare.IColDef

func (*ColumnDef[T]) SetName

func (c *ColumnDef[T]) SetName(name string) *ColumnDef[T]

func (ColumnDef) SrcName

func (c ColumnDef) SrcName() string

func (ColumnDef) StdDev

func (a ColumnDef) StdDev() *aggregatedCol[T]

func (ColumnDef) Sum

func (a ColumnDef) Sum() *aggregatedCol[T]

type ConditionForBuilder

type ConditionForBuilder[T any] struct {
	// contains filtered or unexported fields
}

func NewConditionForBuilder

func NewConditionForBuilder[T any](column preformShare.IColDef) ConditionForBuilder[T]

func (ConditionForBuilder[T]) And

func (ConditionForBuilder[T]) Any

func (c ConditionForBuilder[T]) Any(value any) ConditionForBuilder[T]

func (ConditionForBuilder[T]) Between

func (c ConditionForBuilder[T]) Between(value1, value2 any) ConditionForBuilder[T]

Between

func (ConditionForBuilder[T]) Eq

func (c ConditionForBuilder[T]) Eq(value any) ConditionForBuilder[T]

Eq

func (ConditionForBuilder[T]) Gt

func (c ConditionForBuilder[T]) Gt(value any) ConditionForBuilder[T]

Gt

func (ConditionForBuilder[T]) GtOrEq

func (c ConditionForBuilder[T]) GtOrEq(value any) ConditionForBuilder[T]

GtOrEq

func (ConditionForBuilder[T]) HasAny

func (c ConditionForBuilder[T]) HasAny(value ...any) ConditionForBuilder[T]

HasAny

func (ConditionForBuilder[T]) IAnd

func (ConditionForBuilder[T]) Lt

func (c ConditionForBuilder[T]) Lt(value any) ConditionForBuilder[T]

Lt

func (ConditionForBuilder[T]) LtOrEq

func (c ConditionForBuilder[T]) LtOrEq(value any) ConditionForBuilder[T]

LtOrEq

func (ConditionForBuilder[T]) NotEq

func (c ConditionForBuilder[T]) NotEq(value any) ConditionForBuilder[T]

Neq

func (ConditionForBuilder[T]) Or

func (ConditionForBuilder[T]) ToCode

func (c ConditionForBuilder[T]) ToCode() string

func (ConditionForBuilder[T]) ToCondCode

func (c ConditionForBuilder[T]) ToCondCode() string

func (ConditionForBuilder[T]) UseAlias

type FactoryBuilder

type FactoryBuilder[D iFactoryBuilder] struct {
	Definition D
	// contains filtered or unexported fields
}

func InitFactoryFromTable

func InitFactoryFromTable(table *preformShare.Table, importPaths map[string]struct{}) *FactoryBuilder[iFactoryBuilder]

func (*FactoryBuilder[D]) AddAssociated

func (f *FactoryBuilder[D]) AddAssociated(builder preformShare.IFactoryBuilder)

func (*FactoryBuilder[D]) AddCode

func (f *FactoryBuilder[D]) AddCode(def, model, setting, extraFuncs []string, setRelationCodes [][]string)

func (*FactoryBuilder[D]) AddCustomField

func (f *FactoryBuilder[D]) AddCustomField(name string, valueType reflect.Type)

func (*FactoryBuilder[D]) AddInheritor

func (f *FactoryBuilder[D]) AddInheritor(tableName string) preformShare.IFactoryBuilder

func (*FactoryBuilder[D]) AddInheritorByCondition

func (f *FactoryBuilder[D]) AddInheritorByCondition(codeName string, cond preformShare.ICondForBuilder) preformShare.IFactoryBuilder

func (FactoryBuilder[D]) Alias

func (f FactoryBuilder[D]) Alias() string

func (FactoryBuilder[D]) AllFieldNames

func (f FactoryBuilder[D]) AllFieldNames() map[string]struct{}

func (*FactoryBuilder[D]) AssociatedModelTimes

func (f *FactoryBuilder[D]) AssociatedModelTimes(model preformShare.IFactoryBuilder) int

func (*FactoryBuilder[D]) Clone

func (FactoryBuilder[D]) CodeName

func (f FactoryBuilder[D]) CodeName() string

func (FactoryBuilder[D]) ColSet

func (f FactoryBuilder[D]) ColSet() map[string]preformShare.IColDef

func (FactoryBuilder[D]) Cols

func (f FactoryBuilder[D]) Cols() []preformShare.IColDef

func (FactoryBuilder[D]) FactoryType

func (f FactoryBuilder[D]) FactoryType() reflect.Type

func (*FactoryBuilder[D]) FullCodeName

func (f *FactoryBuilder[D]) FullCodeName() string

func (*FactoryBuilder[D]) IsView

func (f *FactoryBuilder[D]) IsView()

func (*FactoryBuilder[D]) PK

func (f *FactoryBuilder[D]) PK() []preformShare.IColDef

PK

func (FactoryBuilder[D]) SchemaName

func (f FactoryBuilder[D]) SchemaName() string

func (*FactoryBuilder[D]) SetAlias

func (f *FactoryBuilder[D]) SetAlias(alias string) preformShare.IFactoryBuilder

func (*FactoryBuilder[D]) SetTableName

func (f *FactoryBuilder[D]) SetTableName(name string) *FactoryBuilder[D]

func (FactoryBuilder[D]) TableName

func (f FactoryBuilder[D]) TableName() string

type ForeignKeyDef

type ForeignKeyDef[T any] struct {
	*ColumnDef[T]
	// contains filtered or unexported fields
}

func (ForeignKeyDef) Aggregate

func (a ForeignKeyDef) Aggregate(fn preformShare.Aggregator, aggregatedType reflect.Type, params ...any) *aggregatedCol[T]

func (ForeignKeyDef) Alias

func (c ForeignKeyDef) Alias() string

func (ForeignKeyDef[T]) AutoAssociatedCond

func (c ForeignKeyDef[T]) AutoAssociatedCond(factories []preformShare.IFactoryBuilder) preformShare.ICondForBuilder

func (ForeignKeyDef) Avg

func (a ForeignKeyDef) Avg() *aggregatedCol[T]

func (ForeignKeyDef) CodeName

func (c ForeignKeyDef) CodeName() string

func (ForeignKeyDef[T]) ColDef

func (c ForeignKeyDef[T]) ColDef() preformShare.IColDef

func (ForeignKeyDef) Count

func (a ForeignKeyDef) Count() *aggregatedCol[T]

func (ForeignKeyDef) CountDistinct

func (a ForeignKeyDef) CountDistinct() *aggregatedCol[T]

func (ForeignKeyDef) Factory

func (c ForeignKeyDef) Factory() preformShare.IFactoryBuilder

func (ForeignKeyDef[T]) GenerateCode

func (c ForeignKeyDef[T]) GenerateCode(schemaName string, fromQuery bool) (importPath []string, defColCode []string, modelColCode []string, settingCodes []string, extraFunc string)

func (ForeignKeyDef[T]) GetSetRelationCodes

func (c ForeignKeyDef[T]) GetSetRelationCodes() (codes [][]string)

func (ForeignKeyDef) GroupConcat

func (a ForeignKeyDef) GroupConcat(splitter string) *aggregatedCol[T]

func (*ForeignKeyDef[T]) InitCol

func (c *ForeignKeyDef[T]) InitCol(ref *reflect.StructField, builder iFactoryBuilder)

func (ForeignKeyDef) Max

func (a ForeignKeyDef) Max() *aggregatedCol[T]

func (ForeignKeyDef) Mean

func (a ForeignKeyDef) Mean() *aggregatedCol[T]

func (ForeignKeyDef) Median

func (a ForeignKeyDef) Median() *aggregatedCol[T]

func (ForeignKeyDef) Min

func (a ForeignKeyDef) Min() *aggregatedCol[T]

func (ForeignKeyDef) Mode

func (a ForeignKeyDef) Mode() *aggregatedCol[T]

func (ForeignKeyDef) OColName

func (c ForeignKeyDef) OColName() string

func (*ForeignKeyDef[T]) PK

func (c *ForeignKeyDef[T]) PK() *ForeignKeyDef[T]

func (ForeignKeyDef) RelatedFk

func (c ForeignKeyDef) RelatedFk(def preformShare.IColDef) *columnDef[T]

func (ForeignKeyDef) RelatedFks

func (c ForeignKeyDef) RelatedFks() []preformShare.IColDef

func (*ForeignKeyDef[T]) SetAlias

func (c *ForeignKeyDef[T]) SetAlias(alias string) *ForeignKeyDef[T]

func (ForeignKeyDef[T]) SetAliasI

func (c ForeignKeyDef[T]) SetAliasI(alias string) preformShare.IColDef

func (*ForeignKeyDef[T]) SetAssociatedKey

func (c *ForeignKeyDef[T]) SetAssociatedKey(col preformShare.IColDef, setters ...foreignKeyCnfSetter) *ForeignKeyDef[T]

func (*ForeignKeyDef[T]) SetName

func (c *ForeignKeyDef[T]) SetName(name string) *ForeignKeyDef[T]

func (ForeignKeyDef) SrcName

func (c ForeignKeyDef) SrcName() string

func (ForeignKeyDef) StdDev

func (a ForeignKeyDef) StdDev() *aggregatedCol[T]

func (ForeignKeyDef) Sum

func (a ForeignKeyDef) Sum() *aggregatedCol[T]

type PrimaryKeyDef

type PrimaryKeyDef[T any] struct {
	*ForeignKeyDef[T]
}

func (PrimaryKeyDef) Aggregate

func (a PrimaryKeyDef) Aggregate(fn preformShare.Aggregator, aggregatedType reflect.Type, params ...any) *aggregatedCol[T]

func (PrimaryKeyDef) Alias

func (c PrimaryKeyDef) Alias() string

func (*PrimaryKeyDef[T]) AutoIncrement

func (c *PrimaryKeyDef[T]) AutoIncrement() *PrimaryKeyDef[T]

func (PrimaryKeyDef) Avg

func (a PrimaryKeyDef) Avg() *aggregatedCol[T]

func (PrimaryKeyDef) CodeName

func (c PrimaryKeyDef) CodeName() string

func (PrimaryKeyDef) Count

func (a PrimaryKeyDef) Count() *aggregatedCol[T]

func (PrimaryKeyDef) CountDistinct

func (a PrimaryKeyDef) CountDistinct() *aggregatedCol[T]

func (PrimaryKeyDef) Factory

func (c PrimaryKeyDef) Factory() preformShare.IFactoryBuilder

func (PrimaryKeyDef[T]) GenerateCode

func (c PrimaryKeyDef[T]) GenerateCode(schemaName string, fromQuery bool) (importPath []string, defColCode []string, modelColCode []string, settingCodes []string, extraFunc string)

func (PrimaryKeyDef) GroupConcat

func (a PrimaryKeyDef) GroupConcat(splitter string) *aggregatedCol[T]

func (*PrimaryKeyDef[T]) InitCol

func (c *PrimaryKeyDef[T]) InitCol(ref *reflect.StructField, builder iFactoryBuilder)

func (PrimaryKeyDef) Max

func (a PrimaryKeyDef) Max() *aggregatedCol[T]

func (PrimaryKeyDef) Mean

func (a PrimaryKeyDef) Mean() *aggregatedCol[T]

func (PrimaryKeyDef) Median

func (a PrimaryKeyDef) Median() *aggregatedCol[T]

func (PrimaryKeyDef) Min

func (a PrimaryKeyDef) Min() *aggregatedCol[T]

func (PrimaryKeyDef) Mode

func (a PrimaryKeyDef) Mode() *aggregatedCol[T]

func (PrimaryKeyDef) OColName

func (c PrimaryKeyDef) OColName() string

func (PrimaryKeyDef) RelatedFk

func (c PrimaryKeyDef) RelatedFk(def preformShare.IColDef) *columnDef[T]

func (PrimaryKeyDef) RelatedFks

func (c PrimaryKeyDef) RelatedFks() []preformShare.IColDef

func (PrimaryKeyDef) SrcName

func (c PrimaryKeyDef) SrcName() string

func (PrimaryKeyDef) StdDev

func (a PrimaryKeyDef) StdDev() *aggregatedCol[T]

func (PrimaryKeyDef) Sum

func (a PrimaryKeyDef) Sum() *aggregatedCol[T]

type QueryBuilder

type QueryBuilder struct {
	// contains filtered or unexported fields
}

func BuildQuery

func BuildQuery(name string, funcAcceptBuilderPlusModels any) *QueryBuilder

func (*QueryBuilder) Cols

func (builder *QueryBuilder) Cols(cols ...preformShare.IColDef) *QueryBuilder

func (*QueryBuilder) From

func (*QueryBuilder) GenerateCode

func (builder *QueryBuilder) GenerateCode(schemaName string) (name, schemaField, factoryName, defCode, modelCode string, importPaths []string)

func (*QueryBuilder) GroupBy

func (builder *QueryBuilder) GroupBy(stmt ...any) *QueryBuilder

func (*QueryBuilder) Having

func (builder *QueryBuilder) Having(condition preformShare.ICondForBuilder) *QueryBuilder

func (*QueryBuilder) InnerJoin

func (*QueryBuilder) InnerJoinByForeignKey

func (builder *QueryBuilder) InnerJoinByForeignKey(fk foreignKeyForJoin, cond ...preformShare.ICondForBuilder) *QueryBuilderSetAlias

func (*QueryBuilder) LeftJoin

func (*QueryBuilder) LeftJoinByForeignKey

func (builder *QueryBuilder) LeftJoinByForeignKey(fk foreignKeyForJoin, cond ...preformShare.ICondForBuilder) *QueryBuilderSetAlias

func (*QueryBuilder) RightJoin

func (*QueryBuilder) RightJoinByForeignKey

func (builder *QueryBuilder) RightJoinByForeignKey(fk foreignKeyForJoin, cond ...preformShare.ICondForBuilder) *QueryBuilderSetAlias

func (*QueryBuilder) Where

func (builder *QueryBuilder) Where(condition preformShare.ICondForBuilder) *QueryBuilder

type QueryBuilderSetAlias

type QueryBuilderSetAlias struct {
	*QueryBuilder
	// contains filtered or unexported fields
}

func (*QueryBuilderSetAlias) As

func (builder *QueryBuilderSetAlias) As(alias string) *QueryBuilder

type QueryBuilderSrc

type QueryBuilderSrc[T preformShare.IFactoryBuilder] struct {
	// contains filtered or unexported fields
}

func NewQueryBuilderSrc

func NewQueryBuilderSrc[T preformShare.IFactoryBuilder](model T) *QueryBuilderSrc[T]

func (*QueryBuilderSrc[T]) JoinCond

Jump to

Keyboard shortcuts

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