preform

package module
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: 21 Imported by: 1

README

Preform

A productive ORM in GO

MIT license

Compile data models down to column level aim at querying without using any string, by knowing the data types scanning data can be faster than hand-writing rows.Scan even it's still the trusted official drivers.

go 1.18+, currently supports Postgres, Mysql, Clickhouse, Sqlite and more is coming.

Overview

  • Model builder, will build table structure for queries & body type as data container, with custom type & enum supports
  • Relations, eager loading, join with predefined foreign keys / middle table
  • Integrated query builder base on Masterminds/squirrel with type safe output
  • Prebuild complex queries for fast querying & type safe output
  • Condition without string, prebuild columns definition in table structure to avoid using string
  • Type specific scanner, make it faster than native rows.Scan
  • Production grade Performance, avoid using reflect after initialization and other optimization. Please see benchmarks / details
  • Schema wrapping, easy to archive schema data isolation
  • Flexible log and tracing, built in support with zerolog, otel, interface for custom logger/tracer
  • AI friendly, pre-generated code is easy for AI to understand compare to string

Flow chart

Example

Talk is cheap, show me the code!

For more examples, please check test folder

Quering
model.MainSchema.Use(func(mainSchema *model.MainSchema) { // syntax sugar to avoid long prefix chain
  // simple select
  user, err := mainSchema.ModelWithMultipleKeys.Select(). // select all columns
    GetOne("keyValue1", "keyValue2"...)                   // get by primary key value(s)

  // select with eager loading
  user, err := mainSchema.User.Select(mainSchema.User.Id, mainSchema.User.Username). // select columns with predefined column fields
    Where(mainSchema.User.Id.Eq(191234).And(mainSchema.User.Flags.Any(1))).          // condition without hand-writing string
    Eager(mainSchema.User.Orders.Columns(mainSchema.Order.Amount).                   // eager loading with options
        Eager(mainSchema.Order.Products)).                                           // multiple levels eager loading
    Ctx(ctx).GetOne()
  
  // relation loading
  cards, err := user.LoadCards() 
  

  // join query
  rows, err := mainSchema.User.Select(mainSchema.User.Id, mainSchema.User.Username, mainSchema.User.Bookmarks, mainSchema.UserBookmark.Name).
    JoinForeignKey(mainSchema.User.BookmarkIds). // join with predefined foreign key
    Query()
})
CUD
// insert
err = mainSchema.User.Insert(&model.UserBody{...}, preform.EditConfig{Tx: tx, Ctx: ctx}) // with optional insert config

err = mainSchema.User.InsertBatch([]*model.UserBody{...})

err = user.Insert(preform.EditConfig{Cascading: true})

// update
err = user.Update(preform.UpdateConfig{Tx: tx, Ctx: ctx, Cols: []preform.ICol{mainSchema.User.Username}})  // with optional update config

affected, err = mainSchema.User.Update().Set(mainSchema.User.Username, "test").Where(mainSchema.User.Id.Eq(1)).Exec()

// delete
deleted, err = user.Delete(preform.EditConfig{Tx: tx, Ctx: ctx})  // with optional delete config

deleted, err = mainSchema.User.Delete().Where(mainSchema.User.Id.Eq(1)).Exec()
Building models
// build with main.go, using code to generate is more straightforward & flexible than cli IMO
preform.BuildModel(nativeDbConn, "pkgName", "outputPath", "schema1", "schema2" ...) 
Customize model
// models will be generated along with source code in src folder, add go file to define more advanced structure
func (d *MainSchema_order) Setup() (skipAutoSetter bool) {
  d.Status.OverwriteType(preform.ColumnDef[CUSTOM_STATUS_ENUM]{})                // overwrite column type
  d.UserId.SetAssociatedKey(MainSchema.user.Id, preform.FkRelationName("Buyer")) // custom foreign key field, set relation name in this case
  d.CardId.SetAssociatedKey(MainSchema.card.Id)                                  // retain auto joining from original generated code
  return true
}
Prebuild queries
// define in src folder init() as part of customize model
PrebuildQueries = append(PrebuildQueries, queryBuilder.Build("getNotificationCount",
  func(builder *queryBuilder.QueryBuilder, main *MainSchema) {
    builder.From(main.user).
      Cols(
        main.user.Id.SetAlias("UId"),                   // field alias
        main.Notification.Id.Count().SetAlias("Cnt"),   // field alias
        main.Notification.Priority,
      ).
    LeftJoin(main.Notification, main.Notification.TargetIds.Any(main.user.Id).And(main.Notification.Target.Eq(2))).  // joining condition
    Where(main.Notification.Target.Eq(2)).                                                                           // predefine condition
    Having(main.Notification.Status.NotEq(0)).                                                                       // predefine having
    GroupBy(main.user.Id, main.Notification.Priority)                                                                // predefine group by
}))

// query
notes, err := model.GetAdminNotifications.Select(model.GetNotificationCount.Cnt, model.GetNotificationCount.UId). // custom select columns
    Where(model.GetNotificationCount.UId.Eq(1)).                                                                  // additional where condition
    GetAll() // type safe output
Benchmarks
# with local docker postgres, 1000 rows on Apple M1 MAX
goos: darwin
goarch: arm64
pkg: github.com/go-preform/preform/benchmark
BenchmarkPreformSelectAll-20               1107    1114150 ns/op   313897 B/op    12231 allocs/op #1000 rows
BenchmarkPreformSelectAllFast-20           1598     718653 ns/op   260551 B/op     9337 allocs/op #1000 rows
BenchmarkPreformSelectEager-20              327    4195277 ns/op  2111897 B/op    31951 allocs/op #100 rows + 1000 + 1000
BenchmarkPreformSelectEagerFast-20          385    3184728 ns/op  2001004 B/op    25971 allocs/op #100 rows + 1000 + 1000
BenchmarkGormSelectAll-20                   506    2805352 ns/op   416675 B/op    23210 allocs/op #1000 rows
BenchmarkGormSelectEager-20                 129    9838620 ns/op  3537747 B/op    67227 allocs/op #100 rows + 1000 + 1000
BenchmarkEntSelectAll-20                    721    1592649 ns/op   639373 B/op    20357 allocs/op #1000 rows
BenchmarkEntSelectEager-20                  267    5305585 ns/op  2025764 B/op    48888 allocs/op #100 rows + 1000 + 1000
BenchmarkSqlxStructScan-20                  814    1529897 ns/op   651149 B/op    12183 allocs/op #1000 rows
BenchmarkSqlRawScan-20                      874    1350841 ns/op   650702 B/op    12180 allocs/op #1000 rows

Benchmarks

Contributors

Documentation

Index

Constants

View Source
const (
	INSERT_CHUNK_SIZE = 1000
)

Variables

View Source
var Aggr = aggr{}
View Source
var (
	DefaultDB *db
)

Functions

func Aggregate

func Aggregate[T any](fn preformShare.Aggregator, colOrString any, params ...any) iAggregateCol

func DbFromNative

func DbFromNative(d *sql.DB, queryRunner ...preformShare.QueryRunner) *db

func IniPrebuildQueryFactory

func IniPrebuildQueryFactory[FPtr iPrebuildQueryFactory, B any](setter func(d FPtr)) FPtr

func InitFactory

func InitFactory[FPtr IFactory, B any](setter any) func() FPtr

func InitViewFactory

func InitViewFactory[FPtr IViewFactory, B any](setter any) func() FPtr

func PrepareFactories

func PrepareFactories(s ISchema)

func PrepareQueriesAndRelation

func PrepareQueriesAndRelation(s ...ISchema)

Types

type AggregateCol

type AggregateCol[T any] struct {
	ICol
	Aggregator preformShare.Aggregator
	// contains filtered or unexported fields
}

implements ICol

func (*AggregateCol[T]) GetRawPtrScanner

func (a *AggregateCol[T]) GetRawPtrScanner() (vv any, toScanner func(*any) any)

func (*AggregateCol[T]) SetAlias

func (a *AggregateCol[T]) SetAlias(alias string) ICol

func (AggregateCol[T]) ToSql

func (a AggregateCol[T]) ToSql() (string, []any, error)

func (AggregateCol[T]) WithDialect

func (a AggregateCol[T]) WithDialect(d preformShare.IDialect) ICond

type Body

type Body[T hasFactory[F], F IFactory] struct {
	QueryBody[T, F]
	// contains filtered or unexported fields
}

func (Body[T, F]) Delete

func (b Body[T, F]) Delete(body *T, cfg ...EditConfig) (affected int64, err error)

func (Body[T, F]) Factory

func (b Body[T, F]) Factory(defaultFactory F) F

func (Body[T, F]) Insert

func (b Body[T, F]) Insert(body *T, cfg ...EditConfig) error

func (Body[T, F]) SetCol

func (b Body[T, F]) SetCol(body *T, col preformShare.ICol, value any)

func (Body[T, F]) UpdateByPk

func (b Body[T, F]) UpdateByPk(body *T, cfg ...UpdateConfig) (affected int64, err error)

type CaseStmt

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

func (*CaseStmt) Else

func (c *CaseStmt) Else(els any) *CaseStmt

func (*CaseStmt) MustSql

func (c *CaseStmt) MustSql(dialect preformShare.IDialect) (string, []interface{})

func (*CaseStmt) ToExpr

func (c *CaseStmt) ToExpr(dialect preformShare.IDialect) (squirrel.Sqlizer, error)

func (*CaseStmt) ToSql

func (c *CaseStmt) ToSql(dialect preformShare.IDialect) (string, []interface{}, error)

func (*CaseStmt) When

func (c *CaseStmt) When(cond ICond, then any) *CaseStmt

type Column

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

func (Column[T]) Aggregate

func (a Column[T]) Aggregate(fn preformShare.Aggregator, params ...any) iAggregateCol

func (Column[T]) Alias

func (c Column[T]) Alias() string

func (Column) And

func (c Column) And(cond ...ICond) colConditioner

func (Column) Any

func (c Column) Any(v any) colConditioner

func (Column[T]) ArrayAgg

func (a Column[T]) ArrayAgg() iAggregateCol

func (*Column[T]) Asc

func (c *Column[T]) Asc() string

func (Column[T]) Avg

func (a Column[T]) Avg() iAggregateCol

func (Column) Between

func (c Column) Between(v1, v2 any) colConditioner

Between

func (*Column[T]) CaseStmt

func (c *Column[T]) CaseStmt(pkName string) *CaseStmt

func (Column) Col

func (c Column) Col() ICol

func (Column) Concat

func (c Column) Concat(arrayCol any) colConditioner

func (Column) Contains

func (c Column) Contains(arrayCol any) colConditioner

func (Column) ContainsBy

func (c Column) ContainsBy(arrayCol any) colConditioner

func (Column[T]) Count

func (a Column[T]) Count() iAggregateCol

func (Column[T]) CountDistinct

func (a Column[T]) CountDistinct() iAggregateCol

func (Column) DbName

func (c Column) DbName() string

func (*Column[T]) Desc

func (c *Column[T]) Desc() string

func (Column) Eq

func (c Column) Eq(v any) colConditioner

Eq

func (Column) Expr

func (c Column) Expr(exprWithFmt string, args ...any) colConditioner

func (Column[T]) Factory

func (c Column[T]) Factory() IFactory

func (*Column[T]) GetCode

func (c *Column[T]) GetCode() string

func (*Column[T]) GetCodeWithAlias

func (c *Column[T]) GetCodeWithAlias() string

func (Column) GetPos

func (c Column) GetPos() int

func (Column) GetRawPtrScanner

func (c Column) GetRawPtrScanner() (vv any, toScanner func(*any) any)

func (Column[T]) GroupConcat

func (a Column[T]) GroupConcat(splitter string) iAggregateCol

func (Column) Gt

func (c Column) Gt(v any) colConditioner

Gt

func (Column) GtOrEq

func (c Column) GtOrEq(v any) colConditioner

Gte

func (Column) HasAny

func (c Column) HasAny(arrayCol any) colConditioner

func (Column[T]) IsSame

func (c Column[T]) IsSame(cc ICol) bool

func (Column[T]) JsonAgg

func (a Column[T]) JsonAgg() iAggregateCol

func (Column) Like

func (c Column) Like(v any) colConditioner

like

func (Column) Lt

func (c Column) Lt(v any) colConditioner

Lt

func (Column) LtOrEq

func (c Column) LtOrEq(v any) colConditioner

Lte

func (Column[T]) Max

func (a Column[T]) Max() iAggregateCol

func (Column[T]) Mean

func (a Column[T]) Mean() iAggregateCol

func (Column[T]) Median

func (a Column[T]) Median() iAggregateCol

func (Column[T]) Min

func (a Column[T]) Min() iAggregateCol

func (Column[T]) Mode

func (a Column[T]) Mode() iAggregateCol

func (Column) Name

func (c Column) Name() string

func (Column) NewValue

func (c Column) NewValue() any

func (Column) NewZero

func (c Column) NewZero() T

func (Column) NoParentCode

func (c Column) NoParentCode() colConditioner

func (Column) NotEq

func (c Column) NotEq(v any) colConditioner

Neq

func (Column) Or

func (c Column) Or(cond ...ICond) colConditioner

func (Column[T]) ParentModel

func (c Column[T]) ParentModel() any

func (Column[T]) QueryFactory

func (c Column[T]) QueryFactory() IQuery

func (*Column[T]) SetAlias

func (c *Column[T]) SetAlias(alias string) ICol

func (Column) SetValue

func (c Column) SetValue(ptr, value any)

func (Column[T]) StdDev

func (a Column[T]) StdDev() iAggregateCol

func (Column[T]) Sum

func (a Column[T]) Sum() iAggregateCol

func (Column[T]) ToSql

func (c Column[T]) ToSql() (string, []interface{}, error)

type ColumnSetter

type ColumnSetter[T any] struct {
	*Column[T]
}

func SetColumn

func SetColumn[T any](c *Column[T]) *ColumnSetter[T]

func (ColumnSetter) And

func (c ColumnSetter) And(cond ...ICond) colConditioner

func (ColumnSetter) Any

func (c ColumnSetter) Any(v any) colConditioner

func (*ColumnSetter[T]) AutoIncrement

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

func (ColumnSetter) Between

func (c ColumnSetter) Between(v1, v2 any) colConditioner

Between

func (ColumnSetter) Col

func (c ColumnSetter) Col() ICol

func (ColumnSetter) Concat

func (c ColumnSetter) Concat(arrayCol any) colConditioner

func (ColumnSetter) Contains

func (c ColumnSetter) Contains(arrayCol any) colConditioner

func (ColumnSetter) ContainsBy

func (c ColumnSetter) ContainsBy(arrayCol any) colConditioner

func (ColumnSetter) DbName

func (c ColumnSetter) DbName() string

func (ColumnSetter) Eq

func (c ColumnSetter) Eq(v any) colConditioner

Eq

func (ColumnSetter) Expr

func (c ColumnSetter) Expr(exprWithFmt string, args ...any) colConditioner

func (*ColumnSetter[T]) GetCol

func (c *ColumnSetter[T]) GetCol() ICol

func (ColumnSetter) GetPos

func (c ColumnSetter) GetPos() int

func (ColumnSetter) GetRawPtrScanner

func (c ColumnSetter) GetRawPtrScanner() (vv any, toScanner func(*any) any)

func (ColumnSetter) Gt

func (c ColumnSetter) Gt(v any) colConditioner

Gt

func (ColumnSetter) GtOrEq

func (c ColumnSetter) GtOrEq(v any) colConditioner

Gte

func (ColumnSetter) HasAny

func (c ColumnSetter) HasAny(arrayCol any) colConditioner

func (ColumnSetter) Like

func (c ColumnSetter) Like(v any) colConditioner

like

func (ColumnSetter) Lt

func (c ColumnSetter) Lt(v any) colConditioner

Lt

func (ColumnSetter) LtOrEq

func (c ColumnSetter) LtOrEq(v any) colConditioner

Lte

func (ColumnSetter) Name

func (c ColumnSetter) Name() string

func (ColumnSetter) NewValue

func (c ColumnSetter) NewValue() any

func (ColumnSetter) NewZero

func (c ColumnSetter) NewZero() T

func (ColumnSetter) NoParentCode

func (c ColumnSetter) NoParentCode() colConditioner

func (ColumnSetter) NotEq

func (c ColumnSetter) NotEq(v any) colConditioner

Neq

func (ColumnSetter) Or

func (c ColumnSetter) Or(cond ...ICond) colConditioner

func (*ColumnSetter[T]) PK

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

func (*ColumnSetter[T]) SetName

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

func (ColumnSetter) SetValue

func (c ColumnSetter) SetValue(ptr, value any)

type ColumnWrap

type ColumnWrap[C ICol] struct {
	IColWrap
	// contains filtered or unexported fields
}

func (ColumnWrap[T]) Aggregate

func (c ColumnWrap[T]) Aggregate(fn preformShare.Aggregator, params ...any) iAggregateCol

func (ColumnWrap[C]) Alias

func (c ColumnWrap[C]) Alias() string

func (ColumnWrap) And

func (c ColumnWrap) And(cond ...ICond) colConditioner

func (ColumnWrap) Any

func (c ColumnWrap) Any(v any) colConditioner

func (ColumnWrap[C]) ArrayAgg

func (c ColumnWrap[C]) ArrayAgg() iAggregateCol

func (ColumnWrap[C]) Avg

func (c ColumnWrap[C]) Avg() iAggregateCol

func (ColumnWrap) Between

func (c ColumnWrap) Between(v1, v2 any) colConditioner

Between

func (*ColumnWrap[T]) CaseStmt

func (c *ColumnWrap[T]) CaseStmt(pkName string) *CaseStmt

func (ColumnWrap) Col

func (c ColumnWrap) Col() ICol

func (ColumnWrap) Concat

func (c ColumnWrap) Concat(arrayCol any) colConditioner

func (ColumnWrap) Contains

func (c ColumnWrap) Contains(arrayCol any) colConditioner

func (ColumnWrap) ContainsBy

func (c ColumnWrap) ContainsBy(arrayCol any) colConditioner

func (ColumnWrap[C]) Count

func (c ColumnWrap[C]) Count() iAggregateCol

func (ColumnWrap[C]) CountDistinct

func (c ColumnWrap[C]) CountDistinct() iAggregateCol

func (ColumnWrap) Eq

func (c ColumnWrap) Eq(v any) colConditioner

Eq

func (ColumnWrap) Expr

func (c ColumnWrap) Expr(exprWithFmt string, args ...any) colConditioner

func (ColumnWrap[C]) Factory

func (c ColumnWrap[C]) Factory() IFactory

func (*ColumnWrap[T]) GetCode

func (c *ColumnWrap[T]) GetCode() string

func (*ColumnWrap[T]) GetCodeWithAlias

func (c *ColumnWrap[T]) GetCodeWithAlias() string

func (ColumnWrap[C]) GroupConcat

func (c ColumnWrap[C]) GroupConcat(splitter string) iAggregateCol

func (ColumnWrap) Gt

func (c ColumnWrap) Gt(v any) colConditioner

Gt

func (ColumnWrap) GtOrEq

func (c ColumnWrap) GtOrEq(v any) colConditioner

Gte

func (ColumnWrap) HasAny

func (c ColumnWrap) HasAny(arrayCol any) colConditioner

func (ColumnWrap[C]) JsonAgg

func (c ColumnWrap[C]) JsonAgg() iAggregateCol

func (ColumnWrap) Like

func (c ColumnWrap) Like(v any) colConditioner

like

func (ColumnWrap) Lt

func (c ColumnWrap) Lt(v any) colConditioner

Lt

func (ColumnWrap) LtOrEq

func (c ColumnWrap) LtOrEq(v any) colConditioner

Lte

func (ColumnWrap[C]) Max

func (c ColumnWrap[C]) Max() iAggregateCol

func (ColumnWrap[C]) Mean

func (c ColumnWrap[C]) Mean() iAggregateCol

func (ColumnWrap[C]) Median

func (c ColumnWrap[C]) Median() iAggregateCol

func (ColumnWrap[C]) Min

func (c ColumnWrap[C]) Min() iAggregateCol

func (ColumnWrap[C]) Mode

func (c ColumnWrap[C]) Mode() iAggregateCol

func (ColumnWrap) NoParentCode

func (c ColumnWrap) NoParentCode() colConditioner

func (ColumnWrap) NotEq

func (c ColumnWrap) NotEq(v any) colConditioner

Neq

func (ColumnWrap) Or

func (c ColumnWrap) Or(cond ...ICond) colConditioner

func (ColumnWrap[C]) QueryFactory

func (c ColumnWrap[C]) QueryFactory() IQuery

func (*ColumnWrap[C]) SetAlias

func (c *ColumnWrap[C]) SetAlias(alias string) ICol

func (ColumnWrap[C]) StdDev

func (c ColumnWrap[C]) StdDev() iAggregateCol

func (ColumnWrap[C]) Sum

func (c ColumnWrap[C]) Sum() iAggregateCol

func (ColumnWrap) ToSql

func (c ColumnWrap) ToSql() (query string, args []any, err error)

ToSql

type DB

type DB interface {
	preformShare.QueryRunner
	GetDialect() preformShare.IDialect
	Db() *db
	Error(msg string, err error)

	QueryTraceScan(ctx context.Context, query string, args ...interface{}) (rows IRows, err error)
	PrepareTrace(ctx context.Context, query string) (IStmt, error)
}

type DeleteBuilder

type DeleteBuilder[B any] struct {
	Builder preformShare.DeleteBuilder
	// contains filtered or unexported fields
}

func (DeleteBuilder[B]) Ctx

func (b DeleteBuilder[B]) Ctx(ctx context.Context) DeleteBuilder[B]

func (DeleteBuilder[B]) Exec

func (b DeleteBuilder[B]) Exec(tx ...preformShare.QueryRunner) (int64, error)

func (DeleteBuilder[B]) LimitOffset

func (b DeleteBuilder[B]) LimitOffset(limit, offset uint64) DeleteBuilder[B]

func (DeleteBuilder[B]) ToSql

func (b DeleteBuilder[B]) ToSql() (string, []any, error)

func (DeleteBuilder[B]) Where

func (b DeleteBuilder[B]) Where(cond ICond) DeleteBuilder[B]

type EagerLoader

type EagerLoader[SB iModelRelatedBody, TF IFactory, TB any] struct {
	IRelation
	// contains filtered or unexported fields
}

func (*EagerLoader[SrcBody, TargetFactory, TargetBody]) Columns

func (loader *EagerLoader[SrcBody, TargetFactory, TargetBody]) Columns(cols ...any) IEagerLoader

func (*EagerLoader[SrcBody, TargetFactory, TargetBody]) Eager

func (loader *EagerLoader[SrcBody, TargetFactory, TargetBody]) Eager(relation IRelation) IEagerLoader

func (*EagerLoader[SrcBody, TargetFactory, TargetBody]) Limit

func (loader *EagerLoader[SrcBody, TargetFactory, TargetBody]) Limit(limit uint32) IEagerLoader

func (*EagerLoader[SrcBody, TargetFactory, TargetBody]) Offset

func (loader *EagerLoader[SrcBody, TargetFactory, TargetBody]) Offset(offset uint32) IEagerLoader

func (*EagerLoader[SrcBody, TargetFactory, TargetBody]) OrderBy

func (loader *EagerLoader[SrcBody, TargetFactory, TargetBody]) OrderBy(orderBy any) IEagerLoader

func (*EagerLoader[SrcBody, TargetFactory, TargetBody]) Where

func (loader *EagerLoader[SrcBody, TargetFactory, TargetBody]) Where(conds ...ICond) IEagerLoader

type EagerLoaderMt

type EagerLoaderMt[SB iModelRelatedBody, TF IFactory, TB, MTB any] struct {
	*EagerLoader[SB, TF, TB]
}

type EditConfig

type EditConfig struct {
	Tx               *Tx
	Cascading        bool
	Ctx              context.Context
	NoAutoPrimaryKey bool
}

type Factory

type Factory[FPtr IFactory, B any] struct {
	Definition FPtr
	// contains filtered or unexported fields
}

func (Factory[FPtr, B]) Alias

func (f Factory[FPtr, B]) Alias() string

func (Factory) BodyType

func (f Factory) BodyType() reflect.Type

func (Factory[FPtr, B]) Clone

func (f Factory[FPtr, B]) Clone() IFactory

func (Factory) CloneInstance

func (f Factory) CloneInstance(factory IFactory) IFactory

func (Factory) CodeName

func (f Factory) CodeName() string

func (Factory[FPtr, B]) Columns

func (f Factory[FPtr, B]) Columns() []ICol

func (Factory[FPtr, B]) ColumnsByName

func (f Factory[FPtr, B]) ColumnsByName() map[string]ICol

func (Factory[FPtr, B]) Count

func (f Factory[FPtr, B]) Count(cond ...ICond) (uint64, error)

func (Factory[FPtr, B]) Db

func (f Factory[FPtr, B]) Db() *db

func (*Factory[FPtr, B]) Delete

func (f *Factory[FPtr, B]) Delete() DeleteBuilder[B]

func (*Factory[FPtr, B]) DeleteByPk

func (f *Factory[FPtr, B]) DeleteByPk(body any, cfgs ...EditConfig) (Deleted int64, err error)

func (Factory) FieldsByNameNotSafeForClone

func (f Factory) FieldsByNameNotSafeForClone() map[string]preformShare.IField

func (Factory[FPtr, B]) FixedCondition

func (f Factory[FPtr, B]) FixedCondition() ICond

func (Factory[FPtr, B]) GetAll

func (f Factory[FPtr, B]) GetAll(cond ...ICond) ([]B, error)

func (Factory[FPtr, B]) GetOne

func (f Factory[FPtr, B]) GetOne(pkLookup ...any) (*B, error)

func (Factory[FPtr, B]) IModelScanner

func (f Factory[FPtr, B]) IModelScanner() any

func (*Factory[FPtr, B]) Insert

func (f *Factory[FPtr, B]) Insert(body any, cfg ...EditConfig) (err error)

Insert body bodies map maps with cascading and insert id

func (Factory[FPtr, B]) InsertBatch

func (f Factory[FPtr, B]) InsertBatch(bodies any, cfgs ...EditConfig) error

for []*B, []B insert not require insert id and cascading

func (Factory[FPtr, B]) InsertMap

func (f Factory[FPtr, B]) InsertMap(body map[string]any, cfgs ...EditConfig) error

func (Factory[FPtr, B]) InsertOne

func (f Factory[FPtr, B]) InsertOne(body *B, cfgs ...EditConfig) error

func (Factory) NewBody

func (f Factory) NewBody() any

func (Factory) NewBodyPtr

func (f Factory) NewBodyPtr() any

func (Factory) NewModel

func (f Factory) NewModel() B

func (Factory) PkCondByBody

func (f Factory) PkCondByBody(body iModelBody) squirrel.Eq

func (Factory) PkCondByValues

func (f Factory) PkCondByValues(values []any) squirrel.Eq

func (Factory) Pks

func (f Factory) Pks() []ICol

func (*Factory[FPtr, B]) Prepare

func (f *Factory[FPtr, B]) Prepare(s ...ISchema)

func (Factory) Relations

func (f Factory) Relations() map[string]IRelation

func (Factory[FPtr, B]) Schema

func (f Factory[FPtr, B]) Schema() ISchema

func (*Factory[FPtr, B]) Select

func (f *Factory[FPtr, B]) Select(cols ...any) *SelectQuery[B]

func (*Factory[FPtr, B]) SelectAny

func (f *Factory[FPtr, B]) SelectAny(cols ...any) *SelectQuery[any]

func (Factory[FPtr, B]) SetAlias

func (f Factory[FPtr, B]) SetAlias(alias string) IQuery

func (*Factory[FPtr, B]) SetFixedCondition

func (f *Factory[FPtr, B]) SetFixedCondition(cond IColConditioner) *Factory[FPtr, B]

func (Factory) SetModelScanner

func (f Factory) SetModelScanner(scanner IModelScanner[B])

func (*Factory[FPtr, B]) SetSchema

func (f *Factory[FPtr, B]) SetSchema(schema ISchema) IFactory

func (*Factory[FPtr, B]) SetTableName

func (f *Factory[FPtr, B]) SetTableName(name string) *Factory[FPtr, B]

func (Factory) TableName

func (f Factory) TableName() string

func (Factory[FPtr, B]) TableNames

func (f Factory[FPtr, B]) TableNames() []string

func (*Factory[FPtr, B]) Update

func (f *Factory[FPtr, B]) Update() UpdateBuilder[B]

func (*Factory[FPtr, B]) UpdateByPk

func (f *Factory[FPtr, B]) UpdateByPk(body any, cfgs ...UpdateConfig) (updated int64, err error)

UpdateByPk update body by pk, can cascade, will skip pk columns

func (Factory) Use

func (f Factory) Use(fn func(factory FPtr))

syntax sugar to avoid long call chain

type ForeignKey

type ForeignKey[T any] struct {
	*Column[T]
	// contains filtered or unexported fields
}

func (ForeignKey[T]) Alias

func (c ForeignKey[T]) Alias() string

func (ForeignKey) And

func (c ForeignKey) And(cond ...ICond) colConditioner

func (ForeignKey) Any

func (c ForeignKey) Any(v any) colConditioner

func (ForeignKey[T]) AssociatedKeys

func (c ForeignKey[T]) AssociatedKeys() []IColFromFactory

func (ForeignKey) Between

func (c ForeignKey) Between(v1, v2 any) colConditioner

Between

func (ForeignKey) Col

func (c ForeignKey) Col() ICol

func (ForeignKey) Concat

func (c ForeignKey) Concat(arrayCol any) colConditioner

func (ForeignKey) Contains

func (c ForeignKey) Contains(arrayCol any) colConditioner

func (ForeignKey) ContainsBy

func (c ForeignKey) ContainsBy(arrayCol any) colConditioner

func (ForeignKey) DbName

func (c ForeignKey) DbName() string

func (ForeignKey) Eq

func (c ForeignKey) Eq(v any) colConditioner

Eq

func (ForeignKey) Expr

func (c ForeignKey) Expr(exprWithFmt string, args ...any) colConditioner

func (*ForeignKey[T]) GetCode

func (c *ForeignKey[T]) GetCode() string

func (*ForeignKey[T]) GetCodeWithAlias

func (c *ForeignKey[T]) GetCodeWithAlias() string

func (ForeignKey) GetPos

func (c ForeignKey) GetPos() int

func (ForeignKey) GetRawPtrScanner

func (c ForeignKey) GetRawPtrScanner() (vv any, toScanner func(*any) any)

func (ForeignKey) Gt

func (c ForeignKey) Gt(v any) colConditioner

Gt

func (ForeignKey) GtOrEq

func (c ForeignKey) GtOrEq(v any) colConditioner

Gte

func (ForeignKey) HasAny

func (c ForeignKey) HasAny(arrayCol any) colConditioner

func (*ForeignKey[T]) Join

func (c *ForeignKey[T]) Join(col ...IColFromFactory) iForeignKeyJoin

func (ForeignKey) Like

func (c ForeignKey) Like(v any) colConditioner

like

func (ForeignKey) Lt

func (c ForeignKey) Lt(v any) colConditioner

Lt

func (ForeignKey) LtOrEq

func (c ForeignKey) LtOrEq(v any) colConditioner

Lte

func (ForeignKey) Name

func (c ForeignKey) Name() string

func (ForeignKey) NewValue

func (c ForeignKey) NewValue() any

func (ForeignKey) NewZero

func (c ForeignKey) NewZero() T

func (ForeignKey) NoParentCode

func (c ForeignKey) NoParentCode() colConditioner

func (ForeignKey) NotEq

func (c ForeignKey) NotEq(v any) colConditioner

Neq

func (ForeignKey) Or

func (c ForeignKey) Or(cond ...ICond) colConditioner

func (*ForeignKey[T]) SetAlias

func (c *ForeignKey[T]) SetAlias(alias string) ICol

func (ForeignKey) SetValue

func (c ForeignKey) SetValue(ptr, value any)

func (ForeignKey[T]) TargetFactory

func (c ForeignKey[T]) TargetFactory() IFactory

func (ForeignKey[T]) ToJoinSql

func (c ForeignKey[T]) ToJoinSql(queryFactory IQuery) (IQuery, string, []interface{}, error)

func (ForeignKey[T]) ToSql

func (c ForeignKey[T]) ToSql() (string, []interface{}, error)

type ForeignKeyJoin

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

func (ForeignKeyJoin) Join

func (c ForeignKeyJoin) Join(col ...IColFromFactory) iForeignKeyJoin

func (ForeignKeyJoin) TargetFactory

func (c ForeignKeyJoin) TargetFactory() IFactory

func (ForeignKeyJoin) ToJoinSql

func (c ForeignKeyJoin) ToJoinSql(queryFactory IQuery) (IQuery, string, []any, error)

type ForeignKeySetter

type ForeignKeySetter[T any] struct {
	*ColumnSetter[T]
	// contains filtered or unexported fields
}

func SetForeignKey

func SetForeignKey[T any](c *ForeignKey[T]) *ForeignKeySetter[T]

func (ForeignKeySetter) And

func (c ForeignKeySetter) And(cond ...ICond) colConditioner

func (ForeignKeySetter) Any

func (c ForeignKeySetter) Any(v any) colConditioner

func (ForeignKeySetter) Between

func (c ForeignKeySetter) Between(v1, v2 any) colConditioner

Between

func (ForeignKeySetter) Col

func (c ForeignKeySetter) Col() ICol

func (ForeignKeySetter) Concat

func (c ForeignKeySetter) Concat(arrayCol any) colConditioner

func (ForeignKeySetter) Contains

func (c ForeignKeySetter) Contains(arrayCol any) colConditioner

func (ForeignKeySetter) ContainsBy

func (c ForeignKeySetter) ContainsBy(arrayCol any) colConditioner

func (ForeignKeySetter) DbName

func (c ForeignKeySetter) DbName() string

func (ForeignKeySetter) Eq

func (c ForeignKeySetter) Eq(v any) colConditioner

Eq

func (ForeignKeySetter) Expr

func (c ForeignKeySetter) Expr(exprWithFmt string, args ...any) colConditioner

func (ForeignKeySetter) GetPos

func (c ForeignKeySetter) GetPos() int

func (ForeignKeySetter) GetRawPtrScanner

func (c ForeignKeySetter) GetRawPtrScanner() (vv any, toScanner func(*any) any)

func (ForeignKeySetter) Gt

func (c ForeignKeySetter) Gt(v any) colConditioner

Gt

func (ForeignKeySetter) GtOrEq

func (c ForeignKeySetter) GtOrEq(v any) colConditioner

Gte

func (ForeignKeySetter) HasAny

func (c ForeignKeySetter) HasAny(arrayCol any) colConditioner

func (ForeignKeySetter) Like

func (c ForeignKeySetter) Like(v any) colConditioner

like

func (ForeignKeySetter) Lt

func (c ForeignKeySetter) Lt(v any) colConditioner

Lt

func (ForeignKeySetter) LtOrEq

func (c ForeignKeySetter) LtOrEq(v any) colConditioner

Lte

func (ForeignKeySetter) Name

func (c ForeignKeySetter) Name() string

func (ForeignKeySetter) NewValue

func (c ForeignKeySetter) NewValue() any

func (ForeignKeySetter) NewZero

func (c ForeignKeySetter) NewZero() T

func (ForeignKeySetter) NoParentCode

func (c ForeignKeySetter) NoParentCode() colConditioner

func (ForeignKeySetter) NotEq

func (c ForeignKeySetter) NotEq(v any) colConditioner

Neq

func (ForeignKeySetter) Or

func (c ForeignKeySetter) Or(cond ...ICond) colConditioner

func (*ForeignKeySetter[T]) SetRelation

func (s *ForeignKeySetter[T]) SetRelation(related IRelation, col ...IColFromFactory) *ForeignKeySetter[T]

func (ForeignKeySetter) SetValue

func (c ForeignKeySetter) SetValue(ptr, value any)

type ICol

type ICol interface {
	preformShare.ICol

	IColConditioner

	SetAlias(alias string) ICol
	Alias() string
	QueryFactory() IQuery

	Asc() string
	Desc() string

	Aggregate(fn preformShare.Aggregator, params ...any) iAggregateCol
	Sum() iAggregateCol
	Avg() iAggregateCol
	Max() iAggregateCol
	Min() iAggregateCol
	Count() iAggregateCol
	CountDistinct() iAggregateCol
	Mean() iAggregateCol
	Median() iAggregateCol
	Mode() iAggregateCol
	StdDev() iAggregateCol
	JsonAgg() iAggregateCol
	ArrayAgg() iAggregateCol
	GroupConcat(splitter string) iAggregateCol
	CaseStmt(pkName string) *CaseStmt
	IsSame(ICol) bool
	// contains filtered or unexported methods
}

type IColConditioner

type IColConditioner interface {
	ICond
	Col() ICol
	Expr(exprWithFmt string, args ...any) colConditioner
	Eq(v any) colConditioner
	NotEq(v any) colConditioner
	Like(v any) colConditioner
	Gt(v any) colConditioner
	GtOrEq(v any) colConditioner
	Lt(v any) colConditioner
	LtOrEq(v any) colConditioner
	Between(v1, v2 any) colConditioner
	And(cond ...ICond) colConditioner
	Or(cond ...ICond) colConditioner
	Contains(arrCol any) colConditioner
	ContainsBy(arrCol any) colConditioner
	HasAny(arrCol any) colConditioner
	Any(v any) colConditioner
	Concat(arrCol any) colConditioner
	NoParentCode() colConditioner
}

type IColFromFactory

type IColFromFactory interface {
	ICol
	Factory() IFactory
}

type IColWrap

type IColWrap interface {
	preformShare.ICol

	SetAlias(alias string) ICol
	QueryFactory() IQuery

	Asc() string
	Desc() string

	Aggregate(fn preformShare.Aggregator, params ...any) iAggregateCol
	Sum() iAggregateCol
	Avg() iAggregateCol
	Max() iAggregateCol
	Min() iAggregateCol
	Count() iAggregateCol
	Mean() iAggregateCol
	Median() iAggregateCol
	Mode() iAggregateCol
	StdDev() iAggregateCol
	CountDistinct() iAggregateCol
	JsonAgg() iAggregateCol
	ArrayAgg() iAggregateCol
	GroupConcat(splitter string) iAggregateCol
	IsSame(col ICol) bool
	// contains filtered or unexported methods
}

type ICond

type ICond = squirrel.Sqlizer

type IEagerLoader

type IEagerLoader interface {
	IRelation
	// contains filtered or unexported methods
}

type IFactory

type IFactory interface {
	IQuery
	Schema() ISchema
	Pks() []ICol
	PkCondByBody(body iModelBody) squirrel.Eq
	Insert(body any, cfg ...EditConfig) error
	UpdateByPk(body any, cfg ...UpdateConfig) (int64, error)
	DeleteByPk(body any, cfg ...EditConfig) (int64, error)

	SetSchema(schema ISchema) IFactory
	Relations() map[string]IRelation
	SelectAny(cols ...any) *SelectQuery[any]
	Clone() IFactory
	CloneInstance(factory IFactory) IFactory

	FixedCondition() ICond
	IModelScanner() any
	// contains filtered or unexported methods
}

type IForeignKey

type IForeignKey interface {
	ICol
	AssociatedKeys() []IColFromFactory
}

type IModelScanner

type IModelScanner[B any] interface {
	ScanCount(rows IRows) (uint64, error)
	ScanAny(rows IRows, cols []ICol, max uint64) ([]any, error)
	ScanBodies(rows IRows, cols []ICol, max uint64) ([]B, error)
	ScanBodiesFast(rows IRows, cols []ICol, max uint64) ([]B, error)
	ScanBody(row IRow, cols []ICol) (*B, error)
	ScanRaw(rows IRows, colValTpl []func() (any, func(*any) any), max uint64) (*RowsWithCols, error)
	ScanStructs(rows IRows, s any) error
	ToAnyScanner() IModelScanner[any]
}

type IQuery

type IQuery interface {
	preformShare.IQueryFactory
	CodeName() string
	TableName() string

	Alias() string
	SetAlias(alias string) IQuery
	Db() *db
	BodyType() reflect.Type
	Prepare(s ...ISchema)
	Columns() []ICol
	ColumnsByName() map[string]ICol
	NewBodyPtr() any
	NewBody() any
	// contains filtered or unexported methods
}

type IRelation

type IRelation interface {
	InitRelation(localAndForeignKeyPairs ...IColFromFactory) IRelation
	ExtraCond(cond ICond) IRelation
	TargetFactory() IFactory
	LocalFactory() IFactory
	LocalKeys() []IColFromFactory
	ForeignKeys() []IColFromFactory
	Index() uint32

	Eager(IRelation) IEagerLoader
	Columns(...any) IEagerLoader
	Where(...ICond) IEagerLoader
	Limit(uint32) IEagerLoader
	Offset(uint32) IEagerLoader
	OrderBy(any) IEagerLoader

	Name() string

	JoinClause() ForeignKeyJoin
	IsMiddleTable() bool
	// contains filtered or unexported methods
}

type IRow

type IRow interface {
	Scan(...any) error
}

type IRows

type IRows interface {
	Scan(dest ...interface{}) error
	Err() error
	Next() bool
	Close() error
	Columns() ([]string, error)
}

type ISchema

type ISchema interface {
	Name() string
	Clone(name string, db ...*sql.DB) ISchema

	Factories() []IFactory
	FactoriesByName() map[string]IFactory
	Init(schemaName string, instance any, db *sql.DB, queryRunner ...preformShare.QueryRunner)
	PrepareFactories(schemas []ISchema)
	Inherit(s ISchema)
	DbName() string

	Db() *db
	SetTracerToDb(tracer ITracer)
	// contains filtered or unexported methods
}

type IStmt

type IStmt interface {
	Exec(args ...interface{}) (sql.Result, error)
	Query(args ...interface{}) (IRows, error)
	QueryRow(args ...interface{}) *sql.Row
	QueryRowContext(ctx context.Context, args ...interface{}) *sql.Row
	ExecContext(ctx context.Context, args ...interface{}) (sql.Result, error)
	QueryContext(ctx context.Context, args ...interface{}) (IRows, error)
	Close() error
}

type ITracer

type ITracer interface {
	Error(driver, msg string, err error)
	Trace(ctx context.Context, driver, query, txId string, args ...any) (context.Context, func(err error) func(fetched bool, err error))
	TraceExec(ctx context.Context, driver, query, txId string, args ...any) (context.Context, func(res sql.Result, err error))
	HealthLoop(ctx context.Context, db DB)
	SetLv(logLv preformShare.LogLv)
}

type IViewFactory

type IViewFactory interface {
	IFactory
	IsView()
}

type MiddleTable

type MiddleTable[SB iModelRelatedBody, TF IFactory, TB any, MTB any] struct {
	// contains filtered or unexported fields
}

func (MiddleTable) Columns

func (r MiddleTable) Columns(cols ...any) IEagerLoader

func (MiddleTable[SrcBody, TargetFactory, TargetBody, MiddleBody]) Eager

func (r MiddleTable[SrcBody, TargetFactory, TargetBody, MiddleBody]) Eager(relation IRelation) IEagerLoader

func (*MiddleTable[SrcBody, TargetFactory, TargetBody, MiddleBody]) ExtraCond

func (r *MiddleTable[SrcBody, TargetFactory, TargetBody, MiddleBody]) ExtraCond(cond ICond) IRelation

func (MiddleTable) ForeignKeys

func (r MiddleTable) ForeignKeys() []IColFromFactory

func (MiddleTable) Index

func (r MiddleTable) Index() uint32

func (*MiddleTable[SrcBody, TargetFactory, TargetBody, MiddleBody]) InitMtRelation

func (r *MiddleTable[SrcBody, TargetFactory, TargetBody, MiddleBody]) InitMtRelation(middleTable IFactory, localKeys, localKeyRefs, foreignKey, foreignKeyRefs []IColFromFactory) IRelation

func (*MiddleTable[SrcBody, TargetFactory, TargetBody, MiddleBody]) InitRelation

func (r *MiddleTable[SrcBody, TargetFactory, TargetBody, MiddleBody]) InitRelation(localAndForeignKeyPairs ...IColFromFactory) IRelation

deprecated use InitMtRelation

func (MiddleTable[SrcBody, TargetFactory, TargetBody, MiddleBody]) IsMiddleTable

func (r MiddleTable[SrcBody, TargetFactory, TargetBody, MiddleBody]) IsMiddleTable() bool

func (MiddleTable[SrcBody, TargetFactory, TargetBody, MiddleBody]) JoinClause

func (r MiddleTable[SrcBody, TargetFactory, TargetBody, MiddleBody]) JoinClause() ForeignKeyJoin

func (MiddleTable) Limit

func (r MiddleTable) Limit(limit uint32) IEagerLoader

func (MiddleTable[SrcBody, TargetFactory, TargetBody, MiddleBody]) LinkModels

func (r MiddleTable[SrcBody, TargetFactory, TargetBody, MiddleBody]) LinkModels(bodies ...MiddleBody) error

func (MiddleTable[SrcBody, TargetFactory, TargetBody, MiddleBody]) Load

func (r MiddleTable[SrcBody, TargetFactory, TargetBody, MiddleBody]) Load(body SrcBody) error

func (MiddleTable[SrcBody, TargetFactory, TargetBody, MiddleBody]) LoadQuery

func (r MiddleTable[SrcBody, TargetFactory, TargetBody, MiddleBody]) LoadQuery(body SrcBody) *SelectQuery[TargetBody]

func (MiddleTable) LocalFactory

func (r MiddleTable) LocalFactory() IFactory

func (MiddleTable) LocalKeys

func (r MiddleTable) LocalKeys() []IColFromFactory

func (MiddleTable) Name

func (r MiddleTable) Name() string

func (MiddleTable) Offset

func (r MiddleTable) Offset(offset uint32) IEagerLoader

func (MiddleTable) OrderBy

func (r MiddleTable) OrderBy(orderBy any) IEagerLoader

func (*MiddleTable) TargetBody

func (r *MiddleTable) TargetBody() TargetBody

func (MiddleTable) TargetFactory

func (r MiddleTable) TargetFactory() IFactory

func (MiddleTable) Where

func (r MiddleTable) Where(conds ...ICond) IEagerLoader

type NoAggregation

type NoAggregation struct{}

type PrebuildQueryCol

type PrebuildQueryCol[T any, A iAggregation] struct {
	ICol
	// contains filtered or unexported fields
}

func SetPrebuildQueryCol

func SetPrebuildQueryCol[T any, A iAggregation](f iPrebuildQueryFactory, src ICol, c *PrebuildQueryCol[T, A]) *PrebuildQueryCol[T, A]

func (PrebuildQueryCol[T, A]) Factory

func (c PrebuildQueryCol[T, A]) Factory() IFactory

func (PrebuildQueryCol[T, A]) GetCodeWithAlias

func (c PrebuildQueryCol[T, A]) GetCodeWithAlias() string

func (PrebuildQueryCol[T, A]) GetPos

func (c PrebuildQueryCol[T, A]) GetPos() int

func (PrebuildQueryCol[T, A]) QueryFactory

func (c PrebuildQueryCol[T, A]) QueryFactory() IQuery

type PrebuildQueryFactory

type PrebuildQueryFactory[FPtr iPrebuildQueryFactory, B any] struct {
	Query preformShare.SelectBuilder

	SrcByAlias map[string]IFactory
	// contains filtered or unexported fields
}

func (PrebuildQueryFactory[FPtr, B]) AddRelation

func (f PrebuildQueryFactory[FPtr, B]) AddRelation(r IRelation) uint32

func (PrebuildQueryFactory[FPtr, B]) Alias

func (f PrebuildQueryFactory[FPtr, B]) Alias() string

func (PrebuildQueryFactory[FPtr, B]) BodyType

func (f PrebuildQueryFactory[FPtr, B]) BodyType() reflect.Type

func (PrebuildQueryFactory[FPtr, B]) CodeName

func (f PrebuildQueryFactory[FPtr, B]) CodeName() string

func (PrebuildQueryFactory[FPtr, B]) Columns

func (f PrebuildQueryFactory[FPtr, B]) Columns() []ICol

func (PrebuildQueryFactory[FPtr, B]) ColumnsByName

func (f PrebuildQueryFactory[FPtr, B]) ColumnsByName() map[string]ICol

func (*PrebuildQueryFactory[FPtr, B]) Db

func (f *PrebuildQueryFactory[FPtr, B]) Db() *db

func (*PrebuildQueryFactory[FPtr, B]) DefineCols

func (f *PrebuildQueryFactory[FPtr, B]) DefineCols(cols ...any) *PrebuildQueryFactory[FPtr, B]

func (*PrebuildQueryFactory[FPtr, B]) GroupBy

func (f *PrebuildQueryFactory[FPtr, B]) GroupBy(group ...any) *PrebuildQueryFactory[FPtr, B]

group by

func (*PrebuildQueryFactory[FPtr, B]) Having

func (f *PrebuildQueryFactory[FPtr, B]) Having(cond any, extra ...any) *PrebuildQueryFactory[FPtr, B]

having

func (*PrebuildQueryFactory[FPtr, B]) Insert

func (f *PrebuildQueryFactory[FPtr, B]) Insert(body any, cfg ...EditConfig) error

deprecated

func (*PrebuildQueryFactory[FPtr, B]) Join

func (f *PrebuildQueryFactory[FPtr, B]) Join(join string, factory IFactory, cond ...ICond) *PrebuildQueryFactory[FPtr, B]

func (PrebuildQueryFactory[FPtr, B]) NewBody

func (f PrebuildQueryFactory[FPtr, B]) NewBody() any

func (PrebuildQueryFactory[FPtr, B]) NewBodyPtr

func (f PrebuildQueryFactory[FPtr, B]) NewBodyPtr() any

func (*PrebuildQueryFactory[FPtr, B]) NewModel

func (f *PrebuildQueryFactory[FPtr, B]) NewModel() B

func (*PrebuildQueryFactory[FPtr, B]) OrderBy

func (f *PrebuildQueryFactory[FPtr, B]) OrderBy(order ...string) *PrebuildQueryFactory[FPtr, B]

order by

func (PrebuildQueryFactory[FPtr, B]) Parent

func (f PrebuildQueryFactory[FPtr, B]) Parent() string

func (PrebuildQueryFactory[FPtr, B]) PkAndValues

func (f PrebuildQueryFactory[FPtr, B]) PkAndValues(body iModelBody) squirrel.Eq

func (PrebuildQueryFactory[FPtr, B]) Pks

func (f PrebuildQueryFactory[FPtr, B]) Pks() []ICol

func (*PrebuildQueryFactory[FPtr, B]) PreSetWhere

func (f *PrebuildQueryFactory[FPtr, B]) PreSetWhere(cond any, extra ...any) *PrebuildQueryFactory[FPtr, B]

func (*PrebuildQueryFactory[FPtr, B]) Prepare

func (f *PrebuildQueryFactory[FPtr, B]) Prepare(schemas ...ISchema)

func (*PrebuildQueryFactory[FPtr, B]) Select

func (f *PrebuildQueryFactory[FPtr, B]) Select(overwrittenCols ...any) *SelectQuery[B]

func (*PrebuildQueryFactory[FPtr, B]) SetAlias

func (f *PrebuildQueryFactory[FPtr, B]) SetAlias(alias string) IQuery

func (*PrebuildQueryFactory[FPtr, B]) SetModelScanner

func (f *PrebuildQueryFactory[FPtr, B]) SetModelScanner(scanner IModelScanner[B])

func (*PrebuildQueryFactory[FPtr, B]) SetSrc

func (f *PrebuildQueryFactory[FPtr, B]) SetSrc(factory IFactory) *PrebuildQueryFactory[FPtr, B]

func (PrebuildQueryFactory[FPtr, B]) TableName

func (f PrebuildQueryFactory[FPtr, B]) TableName() string

func (PrebuildQueryFactory[FPtr, B]) TableNames

func (f PrebuildQueryFactory[FPtr, B]) TableNames() []string

type PrimaryKey

type PrimaryKey[T any] struct {
	*ForeignKey[T]
}

func (PrimaryKey) And

func (c PrimaryKey) And(cond ...ICond) colConditioner

func (PrimaryKey) Any

func (c PrimaryKey) Any(v any) colConditioner

func (PrimaryKey) Between

func (c PrimaryKey) Between(v1, v2 any) colConditioner

Between

func (PrimaryKey) Col

func (c PrimaryKey) Col() ICol

func (PrimaryKey) Concat

func (c PrimaryKey) Concat(arrayCol any) colConditioner

func (PrimaryKey) Contains

func (c PrimaryKey) Contains(arrayCol any) colConditioner

func (PrimaryKey) ContainsBy

func (c PrimaryKey) ContainsBy(arrayCol any) colConditioner

func (PrimaryKey) DbName

func (c PrimaryKey) DbName() string

func (PrimaryKey) Eq

func (c PrimaryKey) Eq(v any) colConditioner

Eq

func (PrimaryKey) Expr

func (c PrimaryKey) Expr(exprWithFmt string, args ...any) colConditioner

func (PrimaryKey) GetPos

func (c PrimaryKey) GetPos() int

func (PrimaryKey) GetRawPtrScanner

func (c PrimaryKey) GetRawPtrScanner() (vv any, toScanner func(*any) any)

func (PrimaryKey) Gt

func (c PrimaryKey) Gt(v any) colConditioner

Gt

func (PrimaryKey) GtOrEq

func (c PrimaryKey) GtOrEq(v any) colConditioner

Gte

func (PrimaryKey) HasAny

func (c PrimaryKey) HasAny(arrayCol any) colConditioner

func (PrimaryKey) Like

func (c PrimaryKey) Like(v any) colConditioner

like

func (PrimaryKey) Lt

func (c PrimaryKey) Lt(v any) colConditioner

Lt

func (PrimaryKey) LtOrEq

func (c PrimaryKey) LtOrEq(v any) colConditioner

Lte

func (PrimaryKey) Name

func (c PrimaryKey) Name() string

func (PrimaryKey) NewValue

func (c PrimaryKey) NewValue() any

func (PrimaryKey) NewZero

func (c PrimaryKey) NewZero() T

func (PrimaryKey) NoParentCode

func (c PrimaryKey) NoParentCode() colConditioner

func (PrimaryKey) NotEq

func (c PrimaryKey) NotEq(v any) colConditioner

Neq

func (PrimaryKey) Or

func (c PrimaryKey) Or(cond ...ICond) colConditioner

func (PrimaryKey) SetValue

func (c PrimaryKey) SetValue(ptr, value any)

type QueryBody

type QueryBody[T hasQueryFactory[F], F IQuery] struct{}

type RowsWithCols

type RowsWithCols struct {
	Columns []string

	Rows [][]any
	// contains filtered or unexported fields
}

func (RowsWithCols) ToMap

func (b RowsWithCols) ToMap() []map[string]any

type RowsWithTrace

type RowsWithTrace struct {
	*sql.Rows
	// contains filtered or unexported fields
}

func (*RowsWithTrace) Close

func (r *RowsWithTrace) Close() error

func (RowsWithTrace) Next

func (r RowsWithTrace) Next() bool

type Schema

type Schema[TPtr ISchema, T any] struct {
	DB

	SchemaName string
	// contains filtered or unexported fields
}

func (Schema[TPtr, T]) BeginTx

func (s Schema[TPtr, T]) BeginTx(ctx context.Context) (*Tx, error)

func (*Schema[TPtr, T]) Db

func (s *Schema[TPtr, T]) Db() *db

func (*Schema[TPtr, T]) DbName

func (s *Schema[TPtr, T]) DbName() string

func (Schema[TPtr, T]) FactoriesByBodyType

func (s Schema[TPtr, T]) FactoriesByBodyType() map[reflect.Type]IFactory

func (Schema[TPtr, T]) FactoriesByName

func (s Schema[TPtr, T]) FactoriesByName() map[string]IFactory

func (*Schema[TPtr, T]) Inherit

func (s *Schema[TPtr, T]) Inherit(schema ISchema)

func (*Schema[TPtr, T]) Init

func (s *Schema[TPtr, T]) Init(schemaName string, instance any, conn *sql.DB, queryRunner ...preformShare.QueryRunner)

func (Schema[TPtr, T]) Name

func (s Schema[TPtr, T]) Name() string

func (*Schema[TPtr, T]) PrepareFactories

func (s *Schema[TPtr, T]) PrepareFactories(schemas []ISchema)

func (Schema[TPtr, T]) RunTx

func (s Schema[TPtr, T]) RunTx(fn func(t TPtr) error) error

deprecated, slow

func (*Schema[TPtr, T]) SetConn

func (s *Schema[TPtr, T]) SetConn(conn *sql.DB, queryRunner ...preformShare.QueryRunner)

func (*Schema[TPtr, T]) SetTracerToDb

func (s *Schema[TPtr, T]) SetTracerToDb(tracerNilToOff ITracer)

func (*Schema[TPtr, T]) Use

func (s *Schema[TPtr, T]) Use(fn func(s TPtr))

type SelectQuery

type SelectQuery[B any] struct {
	Cols      []ICol
	ColValTpl []func() (vv any, toScanner func(*any) any)
	// contains filtered or unexported fields
}

func SelectByFactory

func SelectByFactory[B any](f IQuery, modelScanner IModelScanner[B], cols ...any) *SelectQuery[B]

func (*SelectQuery[B]) AsSubQuery

func (b *SelectQuery[B]) AsSubQuery(alias string) squirrel.Sqlizer

func (*SelectQuery[B]) Column

func (b *SelectQuery[B]) Column(column interface{}, args ...interface{}) *SelectQuery[B]

func (*SelectQuery[B]) Columns

func (b *SelectQuery[B]) Columns(cols ...any) *SelectQuery[B]

func (SelectQuery[B]) Count

func (b SelectQuery[B]) Count(col ...string) (uint64, error)

func (*SelectQuery[B]) CrossJoin

func (b *SelectQuery[B]) CrossJoin(join string, rest ...interface{}) *SelectQuery[B]

func (*SelectQuery[B]) CrossJoinForeignKey

func (b *SelectQuery[B]) CrossJoinForeignKey(joinKey iForeignKeyJoin) *SelectQuery[B]

func (*SelectQuery[B]) CrossRelation

func (b *SelectQuery[B]) CrossRelation(rel IRelation) *SelectQuery[B]

func (*SelectQuery[B]) Ctx

func (b *SelectQuery[B]) Ctx(ctx context.Context) *SelectQuery[B]

func (*SelectQuery[B]) Distinct

func (b *SelectQuery[B]) Distinct() *SelectQuery[B]

func (*SelectQuery[B]) Eager

func (b *SelectQuery[B]) Eager(relation ...IRelation) *SelectQuery[B]

func (*SelectQuery[B]) From

func (b *SelectQuery[B]) From(from any) *SelectQuery[B]

func (*SelectQuery[B]) FromSelect

func (b *SelectQuery[B]) FromSelect(from preformShare.SelectBuilder, alias string) *SelectQuery[B]

func (*SelectQuery[B]) FromSubQuery

func (b *SelectQuery[B]) FromSubQuery(from *subQueryCol, alias string) *SelectQuery[B]

func (SelectQuery[B]) GetAll

func (b SelectQuery[B]) GetAll(cond ...ICond) ([]B, error)

func (SelectQuery[B]) GetAllFast

func (b SelectQuery[B]) GetAllFast(cond ...ICond) ([]B, error)

func (SelectQuery[B]) GetOne

func (b SelectQuery[B]) GetOne(pkLookup ...any) (*B, error)

func (*SelectQuery[B]) GroupBy

func (b *SelectQuery[B]) GroupBy(groupBys ...any) *SelectQuery[B]

func (*SelectQuery[B]) Having

func (b *SelectQuery[B]) Having(pred interface{}, rest ...interface{}) *SelectQuery[B]

func (*SelectQuery[B]) InnerJoin

func (b *SelectQuery[B]) InnerJoin(join string, rest ...interface{}) *SelectQuery[B]

func (*SelectQuery[B]) InnerJoinForeignKey

func (b *SelectQuery[B]) InnerJoinForeignKey(joinKey iForeignKeyJoin) *SelectQuery[B]

func (*SelectQuery[B]) InnerRelation

func (b *SelectQuery[B]) InnerRelation(rel IRelation) *SelectQuery[B]

func (*SelectQuery[B]) Join

func (b *SelectQuery[B]) Join(join string, rest ...interface{}) *SelectQuery[B]

func (*SelectQuery[B]) JoinClause

func (b *SelectQuery[B]) JoinClause(pred interface{}, args ...interface{}) *SelectQuery[B]

func (*SelectQuery[B]) JoinForeignKey

func (b *SelectQuery[B]) JoinForeignKey(joinKey iForeignKeyJoin) *SelectQuery[B]

func (*SelectQuery[B]) JoinRelation

func (b *SelectQuery[B]) JoinRelation(rel IRelation) *SelectQuery[B]

func (*SelectQuery[B]) LeftJoin

func (b *SelectQuery[B]) LeftJoin(join string, rest ...interface{}) *SelectQuery[B]

func (*SelectQuery[B]) LeftJoinForeignKey

func (b *SelectQuery[B]) LeftJoinForeignKey(joinKey iForeignKeyJoin) *SelectQuery[B]

func (*SelectQuery[B]) LeftRelation

func (b *SelectQuery[B]) LeftRelation(rel IRelation) *SelectQuery[B]

func (*SelectQuery[B]) Limit

func (b *SelectQuery[B]) Limit(limit uint64) *SelectQuery[B]

func (SelectQuery[B]) MustSql

func (b SelectQuery[B]) MustSql() (string, []interface{})

func (*SelectQuery[B]) Offset

func (b *SelectQuery[B]) Offset(offset uint64) *SelectQuery[B]

func (*SelectQuery[B]) Options

func (b *SelectQuery[B]) Options(options ...string) *SelectQuery[B]

func (*SelectQuery[B]) OrderBy

func (b *SelectQuery[B]) OrderBy(orderBys ...string) *SelectQuery[B]

func (*SelectQuery[B]) OrderByClause

func (b *SelectQuery[B]) OrderByClause(pred interface{}, args ...interface{}) *SelectQuery[B]

func (*SelectQuery[B]) PlaceholderFormat

func (b *SelectQuery[B]) PlaceholderFormat(f squirrel.PlaceholderFormat) *SelectQuery[B]

func (*SelectQuery[B]) Prefix

func (b *SelectQuery[B]) Prefix(sql string, args ...interface{}) *SelectQuery[B]

func (*SelectQuery[B]) PrefixExpr

func (b *SelectQuery[B]) PrefixExpr(expr ICond) *SelectQuery[B]

func (*SelectQuery[B]) Prepare

func (b *SelectQuery[B]) Prepare() (*SelectQuery[B], error)

func (SelectQuery[B]) Query

func (b SelectQuery[B]) Query() (*sql.Rows, error)

func (SelectQuery[B]) QueryAnys

func (b SelectQuery[B]) QueryAnys() ([]any, error)

func (SelectQuery[B]) QueryBodies

func (b SelectQuery[B]) QueryBodies() ([]B, error)

func (SelectQuery[B]) QueryBodiesFast

func (b SelectQuery[B]) QueryBodiesFast() ([]B, error)

func (SelectQuery[B]) QueryBody

func (b SelectQuery[B]) QueryBody() (*B, error)

func (SelectQuery[B]) QueryRaw

func (b SelectQuery[B]) QueryRaw() (*RowsWithCols, error)

func (SelectQuery[B]) QueryRow

func (b SelectQuery[B]) QueryRow() *sqlRow

func (SelectQuery[B]) QueryRowx

func (b SelectQuery[B]) QueryRowx() *sqlRow

func (SelectQuery[B]) QueryStructs

func (b SelectQuery[B]) QueryStructs(s any) error

func (SelectQuery[B]) Queryx

func (b SelectQuery[B]) Queryx() (*sqlx.Rows, error)

func (*SelectQuery[B]) QuoteIdentifier

func (b *SelectQuery[B]) QuoteIdentifier(id string) string

func (*SelectQuery[B]) RemoveColumns

func (b *SelectQuery[B]) RemoveColumns() *SelectQuery[B]

func (*SelectQuery[B]) RemoveLimit

func (b *SelectQuery[B]) RemoveLimit() *SelectQuery[B]

func (*SelectQuery[B]) RemoveOffset

func (b *SelectQuery[B]) RemoveOffset() *SelectQuery[B]

func (*SelectQuery[B]) RightJoin

func (b *SelectQuery[B]) RightJoin(join string, rest ...interface{}) *SelectQuery[B]

func (*SelectQuery[B]) RightJoinForeignKey

func (b *SelectQuery[B]) RightJoinForeignKey(joinKey iForeignKeyJoin) *SelectQuery[B]

func (*SelectQuery[B]) RightRelation

func (b *SelectQuery[B]) RightRelation(rel IRelation) *SelectQuery[B]

func (*SelectQuery[B]) Suffix

func (b *SelectQuery[B]) Suffix(sql string, args ...interface{}) *SelectQuery[B]

func (*SelectQuery[B]) SuffixExpr

func (b *SelectQuery[B]) SuffixExpr(expr squirrel.Sqlizer) *SelectQuery[B]

func (SelectQuery[B]) ToSql

func (b SelectQuery[B]) ToSql() (string, []interface{}, error)

func (*SelectQuery[B]) Where

func (b *SelectQuery[B]) Where(pred interface{}, args ...interface{}) *SelectQuery[B]

type StmtWithTrace

type StmtWithTrace struct {
	*sql.Stmt
	// contains filtered or unexported fields
}

func (*StmtWithTrace) Exec

func (s *StmtWithTrace) Exec(args ...interface{}) (res sql.Result, err error)

func (*StmtWithTrace) ExecContext

func (s *StmtWithTrace) ExecContext(ctx context.Context, args ...interface{}) (res sql.Result, err error)

func (*StmtWithTrace) Query

func (s *StmtWithTrace) Query(args ...interface{}) (rows IRows, err error)

func (*StmtWithTrace) QueryContext

func (s *StmtWithTrace) QueryContext(ctx context.Context, args ...interface{}) (rows IRows, err error)

func (*StmtWithTrace) QueryRow

func (s *StmtWithTrace) QueryRow(args ...interface{}) (row *sql.Row)

func (*StmtWithTrace) QueryRowContext

func (s *StmtWithTrace) QueryRowContext(ctx context.Context, args ...interface{}) (row *sql.Row)

type ToMany

type ToMany[SB iModelRelatedBody, TF IFactory, TB any] struct {
	// contains filtered or unexported fields
}

func (ToMany) Columns

func (r ToMany) Columns(cols ...any) IEagerLoader

func (*ToMany) Eager

func (r *ToMany) Eager(relation IRelation) IEagerLoader

func (*ToMany[SrcBody, TargetFactory, TargetBody]) ExtraCond

func (r *ToMany[SrcBody, TargetFactory, TargetBody]) ExtraCond(cond ICond) IRelation

func (ToMany) ForeignKeys

func (r ToMany) ForeignKeys() []IColFromFactory

func (ToMany) Index

func (r ToMany) Index() uint32

func (*ToMany[SrcBody, TargetFactory, TargetBody]) InitRelation

func (r *ToMany[SrcBody, TargetFactory, TargetBody]) InitRelation(localAndForeignKeyPairs ...IColFromFactory) IRelation

func (ToMany) IsMiddleTable

func (r ToMany) IsMiddleTable() bool

func (ToMany) JoinClause

func (r ToMany) JoinClause() ForeignKeyJoin

func (ToMany) Limit

func (r ToMany) Limit(limit uint32) IEagerLoader

func (ToMany) Load

func (r ToMany) Load(body SrcBody) error

func (ToMany) LoadQuery

func (r ToMany) LoadQuery(body SrcBody) *SelectQuery[TargetBody]

func (ToMany) LocalFactory

func (r ToMany) LocalFactory() IFactory

func (ToMany) LocalKeys

func (r ToMany) LocalKeys() []IColFromFactory

func (ToMany) Name

func (r ToMany) Name() string

func (ToMany) Offset

func (r ToMany) Offset(offset uint32) IEagerLoader

func (ToMany) OrderBy

func (r ToMany) OrderBy(orderBy any) IEagerLoader

func (*ToMany) TargetBody

func (r *ToMany) TargetBody() TargetBody

func (ToMany) TargetFactory

func (r ToMany) TargetFactory() IFactory

func (ToMany) Where

func (r ToMany) Where(conds ...ICond) IEagerLoader

type ToOne

type ToOne[SB iModelRelatedBody, TF IFactory, TB any] struct {
	// contains filtered or unexported fields
}

func (ToOne) Columns

func (r ToOne) Columns(cols ...any) IEagerLoader

func (*ToOne) Eager

func (r *ToOne) Eager(relation IRelation) IEagerLoader

func (*ToOne[SrcBody, TargetFactory, TargetBody]) ExtraCond

func (r *ToOne[SrcBody, TargetFactory, TargetBody]) ExtraCond(cond ICond) IRelation

func (ToOne) ForeignKeys

func (r ToOne) ForeignKeys() []IColFromFactory

func (ToOne) Index

func (r ToOne) Index() uint32

func (*ToOne[SrcBody, TargetFactory, TargetBody]) InitRelation

func (r *ToOne[SrcBody, TargetFactory, TargetBody]) InitRelation(localAndForeignKeyPairs ...IColFromFactory) IRelation

func (ToOne) IsMiddleTable

func (r ToOne) IsMiddleTable() bool

func (ToOne) JoinClause

func (r ToOne) JoinClause() ForeignKeyJoin

func (ToOne) Limit

func (r ToOne) Limit(limit uint32) IEagerLoader

func (ToOne) Load

func (r ToOne) Load(body SrcBody) error

func (ToOne) LoadQuery

func (r ToOne) LoadQuery(body SrcBody) *SelectQuery[TargetBody]

func (ToOne) LocalFactory

func (r ToOne) LocalFactory() IFactory

func (ToOne) LocalKeys

func (r ToOne) LocalKeys() []IColFromFactory

func (ToOne) Name

func (r ToOne) Name() string

func (ToOne) Offset

func (r ToOne) Offset(offset uint32) IEagerLoader

func (ToOne) OrderBy

func (r ToOne) OrderBy(orderBy any) IEagerLoader

func (*ToOne) TargetBody

func (r *ToOne) TargetBody() TargetBody

func (ToOne) TargetFactory

func (r ToOne) TargetFactory() IFactory

func (ToOne) Where

func (r ToOne) Where(conds ...ICond) IEagerLoader

type Tx

type Tx struct {
	preformShare.QueryRunner
	// contains filtered or unexported fields
}

func (*Tx) Commit

func (t *Tx) Commit() error

func (*Tx) Db

func (t *Tx) Db() *db

func (*Tx) Error

func (t *Tx) Error(msg string, err error)

func (*Tx) GetDialect

func (t *Tx) GetDialect() preformShare.IDialect

func (*Tx) PrepareTrace

func (t *Tx) PrepareTrace(ctx context.Context, query string) (IStmt, error)

func (*Tx) QueryTraceScan

func (t *Tx) QueryTraceScan(ctx context.Context, query string, args ...interface{}) (rows IRows, err error)

func (*Tx) Rollback

func (t *Tx) Rollback() error

type UpdateBuilder

type UpdateBuilder[B any] struct {
	Builder preformShare.UpdateBuilder
	// contains filtered or unexported fields
}

func (UpdateBuilder[B]) Columns

func (b UpdateBuilder[B]) Columns(cols ...ICol) UpdateBuilder[B]

func (UpdateBuilder[B]) Ctx

func (b UpdateBuilder[B]) Ctx(ctx context.Context) UpdateBuilder[B]

func (UpdateBuilder[B]) Exec

func (b UpdateBuilder[B]) Exec(tx ...preformShare.QueryRunner) (int64, error)

func (UpdateBuilder[B]) LimitOffset

func (b UpdateBuilder[B]) LimitOffset(limit, offset uint64) UpdateBuilder[B]

func (UpdateBuilder[B]) Set

func (b UpdateBuilder[B]) Set(col any, value any) UpdateBuilder[B]

func (UpdateBuilder[B]) SetBodies

func (b UpdateBuilder[B]) SetBodies(body ...*B) UpdateBuilder[B]

func (UpdateBuilder[B]) SetMap

func (b UpdateBuilder[B]) SetMap(clause map[string]any) UpdateBuilder[B]

func (UpdateBuilder[B]) ToSql

func (b UpdateBuilder[B]) ToSql() (string, []any, error)

func (UpdateBuilder[B]) Where

func (b UpdateBuilder[B]) Where(cond ICond) UpdateBuilder[B]

type UpdateConfig

type UpdateConfig struct {
	Tx        *Tx
	Cascading bool
	Cols      []ICol
	Ctx       context.Context
}

type ViewFactory

type ViewFactory[FPtr IFactory, B any] struct {
	*Factory[FPtr, B]
}

func (ViewFactory) BodyType

func (f ViewFactory) BodyType() reflect.Type

func (ViewFactory[FPtr, B]) Clone

func (f ViewFactory[FPtr, B]) Clone() IFactory

func (ViewFactory) CloneInstance

func (f ViewFactory) CloneInstance(factory IFactory) IFactory

func (ViewFactory) CodeName

func (f ViewFactory) CodeName() string

func (*ViewFactory[FPtr, B]) DeleteByPk

func (f *ViewFactory[FPtr, B]) DeleteByPk(body any, cfg ...EditConfig) (int64, error)

func (ViewFactory) FieldsByNameNotSafeForClone

func (f ViewFactory) FieldsByNameNotSafeForClone() map[string]preformShare.IField

func (*ViewFactory[FPtr, B]) Insert

func (f *ViewFactory[FPtr, B]) Insert(body any, cfg ...EditConfig) error

func (ViewFactory[FPtr, B]) IsView

func (f ViewFactory[FPtr, B]) IsView()

func (ViewFactory) NewBody

func (f ViewFactory) NewBody() any

func (ViewFactory) NewBodyPtr

func (f ViewFactory) NewBodyPtr() any

func (ViewFactory) NewModel

func (f ViewFactory) NewModel() B

func (ViewFactory) PkCondByBody

func (f ViewFactory) PkCondByBody(body iModelBody) squirrel.Eq

func (ViewFactory) PkCondByValues

func (f ViewFactory) PkCondByValues(values []any) squirrel.Eq

func (ViewFactory) Pks

func (f ViewFactory) Pks() []ICol

func (ViewFactory) Relations

func (f ViewFactory) Relations() map[string]IRelation

func (ViewFactory[FPtr, B]) SetAlias

func (f ViewFactory[FPtr, B]) SetAlias(alias string) IQuery

func (ViewFactory) SetModelScanner

func (f ViewFactory) SetModelScanner(scanner IModelScanner[B])

func (*ViewFactory[FPtr, B]) SetSchema

func (f *ViewFactory[FPtr, B]) SetSchema(schema ISchema) IFactory

func (*ViewFactory[FPtr, B]) SetTableName

func (f *ViewFactory[FPtr, B]) SetTableName(name string) *ViewFactory[FPtr, B]

func (ViewFactory) TableName

func (f ViewFactory) TableName() string

func (*ViewFactory[FPtr, B]) UpdateByPk

func (f *ViewFactory[FPtr, B]) UpdateByPk(body any, cfg ...UpdateConfig) (int64, error)

func (ViewFactory) Use

func (f ViewFactory) Use(fn func(factory FPtr))

syntax sugar to avoid long call chain

Jump to

Keyboard shortcuts

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