Documentation
¶
Overview ¶
Package model contains Schema type and methods
Index ¶
- func MoveItemTx[I, D any](rqtx *my.Request, insertSchema *Schema[I], item *I, deleteSchema *Schema[D], ...) error
- type AutoItem
- type CodeField
- type CreatedAtField
- type Date
- type DateTime
- type GetOrCreateAndLockParams
- type GetOrCreateParams
- type ID
- type IDField
- type Identity
- type IsActiveField
- type Item
- type Schema
- func AddSchema[T any](this *qb.Instance, structRef *T, table string, errs []error) *Schema[T]
- func AddSharedSchema[T any](this *qb.Instance, structRef *T, errs []error) *Schema[T]
- func NewSchema[T any](this *qb.Instance, structRef *T, table string) (*Schema[T], error)
- func NewSharedSchema[T any](this *qb.Instance, structRef *T) (*Schema[T], error)
- func (s *Schema[T]) Count(rq *my.Request, condition qb.Condition) (int, error)
- func (s *Schema[T]) CountAt(rq *my.Request, condition qb.Condition, table string) (int, error)
- func (s *Schema[T]) Delete(rq *my.Request, condition qb.Condition) (int, error)
- func (s *Schema[T]) DeleteAt(rq *my.Request, condition qb.Condition, table string) (int, error)
- func (s *Schema[T]) DeleteTx(rqtx *my.Request, condition qb.Condition) (int, error)
- func (s *Schema[T]) DeleteTxAt(rqtx *my.Request, condition qb.Condition, table string) (int, error)
- func (s *Schema[T]) Get(rq *my.Request, condition qb.Condition) (T, error)
- func (s *Schema[T]) GetAllRows(rq *my.Request) ([]T, error)
- func (s *Schema[T]) GetAllRowsAt(rq *my.Request, table string) ([]T, error)
- func (s *Schema[T]) GetAllRowsOnly(rq *my.Request, fieldNames ...string) ([]dict.Object, error)
- func (s *Schema[T]) GetAllRowsOnlyAt(rq *my.Request, table string, fieldNames ...string) ([]dict.Object, error)
- func (s *Schema[T]) GetAndLockTx(rqtx *my.Request, lockField *bool, selectCondition qb.Condition, ...) (T, error)
- func (s *Schema[T]) GetAndLockTxItems(rqtx *my.Request, lockField *bool, selectCondition qb.Condition, ...) ([]T, error)
- func (s *Schema[T]) GetAt(rq *my.Request, condition qb.Condition, table string) (T, error)
- func (s *Schema[T]) GetOnly(rq *my.Request, condition qb.Condition, fieldNames ...string) (dict.Object, error)
- func (s *Schema[T]) GetOnlyAt(rq *my.Request, condition qb.Condition, table string, fieldNames ...string) (dict.Object, error)
- func (s *Schema[T]) GetOrCreate(rq *my.Request, p *GetOrCreateParams[T]) (T, error)
- func (s *Schema[T]) GetOrCreateAndLockTx(rqtx *my.Request, p *GetOrCreateAndLockParams[T]) (T, error)
- func (s *Schema[T]) GetOrCreateTx(rqtx *my.Request, p *GetOrCreateParams[T]) (T, error)
- func (s *Schema[T]) GetRows(rq *my.Request, condition qb.Condition) ([]T, error)
- func (s *Schema[T]) GetRowsAt(rq *my.Request, condition qb.Condition, table string) ([]T, error)
- func (s *Schema[T]) GetRowsOnly(rq *my.Request, condition qb.Condition, fieldNames ...string) ([]dict.Object, error)
- func (s *Schema[T]) GetRowsOnlyAt(rq *my.Request, condition qb.Condition, table string, fieldNames ...string) ([]dict.Object, error)
- func (s *Schema[T]) Insert(rq *my.Request, item *T) (ID, error)
- func (s *Schema[T]) InsertAt(rq *my.Request, item *T, table string) (ID, error)
- func (s *Schema[T]) InsertRows(rq *my.Request, items []T) error
- func (s *Schema[T]) InsertRowsAt(rq *my.Request, items []T, table string) error
- func (s *Schema[T]) InsertTx(rqtx *my.Request, item *T) (ID, error)
- func (s *Schema[T]) InsertTxAt(rqtx *my.Request, item *T, table string) (ID, error)
- func (s *Schema[T]) InsertTxRows(rqtx *my.Request, items []T) error
- func (s *Schema[T]) InsertTxRowsAt(rqtx *my.Request, items []T, table string) error
- func (s *Schema[T]) SetFlag(rq *my.Request, condition qb.Condition, field *bool, flag bool) error
- func (s *Schema[T]) SetFlagAt(rq *my.Request, condition qb.Condition, field *bool, flag bool, table string) error
- func (s *Schema[T]) SetFlags(rq *my.Request, condition qb.Condition, field *bool, flag bool, numItems int) error
- func (s *Schema[T]) SetFlagsAt(rq *my.Request, condition qb.Condition, field *bool, flag bool, numItems int, ...) error
- func (s *Schema[T]) SetTxFlag(rqtx *my.Request, condition qb.Condition, field *bool, flag bool) error
- func (s *Schema[T]) SetTxFlagAt(rqtx *my.Request, condition qb.Condition, field *bool, flag bool, table string) error
- func (s *Schema[T]) SetTxFlags(rqtx *my.Request, condition qb.Condition, field *bool, flag bool, numItems int) error
- func (s *Schema[T]) SetTxFlagsAt(rqtx *my.Request, condition qb.Condition, field *bool, flag bool, numItems int, ...) error
- func (s *Schema[T]) Sum(rq *my.Request, columns []string, reader qb.RowReader[T], ...) (T, error)
- func (s *Schema[T]) SumAt(rq *my.Request, columns []string, reader qb.RowReader[T], ...) (T, error)
- func (s *Schema[T]) ToggleCode(rq *my.Request, code string, isActive bool, Items *Schema[Item]) error
- func (s *Schema[T]) ToggleCodeAt(rq *my.Request, code string, isActive bool, table string, Items *Schema[Item]) error
- func (s *Schema[T]) ToggleID(rq *my.Request, id ID, isActive bool, Items *Schema[Item]) error
- func (s *Schema[T]) ToggleIDAt(rq *my.Request, id ID, isActive bool, table string, Items *Schema[Item]) error
- func (s *Schema[T]) ToggleTxCode(rqtx *my.Request, code string, isActive bool, Items *Schema[Item]) error
- func (s *Schema[T]) ToggleTxCodeAt(rqtx *my.Request, code string, isActive bool, table string, ...) error
- func (s *Schema[T]) ToggleTxID(rqtx *my.Request, id ID, isActive bool, Items *Schema[Item]) error
- func (s *Schema[T]) ToggleTxIDAt(rqtx *my.Request, id ID, isActive bool, table string, Items *Schema[Item]) error
- func (s *Schema[T]) Update(rq *my.Request, updateFn UpdateFn[T], condition qb.Condition) error
- func (s *Schema[T]) UpdateAndGetTx(rqtx *my.Request, updateFn UpdateFn[T], ...) (T, error)
- func (s *Schema[T]) UpdateAt(rq *my.Request, updateFn UpdateFn[T], condition qb.Condition, table string) error
- func (s *Schema[T]) UpdateFields(rq *my.Request, updates qb.FieldUpdates, condition qb.Condition) error
- func (s *Schema[T]) UpdateFieldsAt(rq *my.Request, updates qb.FieldUpdates, condition qb.Condition, table string) error
- func (s *Schema[T]) UpdateTx(rqtx *my.Request, updateFn UpdateFn[T], condition qb.Condition) error
- func (s *Schema[T]) UpdateTxAt(rqtx *my.Request, updateFn UpdateFn[T], condition qb.Condition, table string) error
- func (s *Schema[T]) UpdateTxFields(rqtx *my.Request, updates qb.FieldUpdates, condition qb.Condition) error
- func (s *Schema[T]) UpdateTxFieldsAt(rqtx *my.Request, updates qb.FieldUpdates, condition qb.Condition, ...) error
- type UpdateFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AutoItem ¶
type AutoItem struct {
IDField
CreatedAtField
IsActiveField
}
AutoItem combines IDField, CreatedAtField, IsActiveField
func (*AutoItem) Initialize ¶
func (x *AutoItem) Initialize()
Initialize sets the ID, CreatedAt, IsActive to default values
type CreatedAtField ¶
type CreatedAtField struct {
CreatedAt DateTime
}
CreatedAtField is an embeddable CreatedAt property
func (CreatedAtField) GetDateTime ¶
func (x CreatedAtField) GetDateTime() DateTime
type GetOrCreateAndLockParams ¶
type GetOrCreateAndLockParams[T any] struct { GetOrCreateParams[T] LockField *bool LockConditionFn func(T) qb.Condition }
type GetOrCreateParams ¶
type IsActiveField ¶
type IsActiveField struct {
IsActive bool
}
IsActiveField is an embeddable IsActive property
func (*IsActiveField) GetIsActive ¶
func (x *IsActiveField) GetIsActive() bool
func (*IsActiveField) SetIsActive ¶
func (x *IsActiveField) SetIsActive(isActive bool)
type Item ¶
Item combines IDField, CreatedAtField, IsActiveField, CodeField
func (*Item) Initialize ¶
func (x *Item) Initialize()
Initialize sets the ID, CreatedAt, IsActive to default values
type Schema ¶
type Schema[T any] struct { Name string Ref *T Table string Reader qb.RowReader[T] Instance *qb.Instance }
func AddSharedSchema ¶
AddSharedSchema adds a new shared Schema (no table) and adds error to the error list if any
func NewSharedSchema ¶
NewSharedSchema creates a new shared Schema (no table)
func (*Schema[T]) Delete ¶
Delete performs a DeleteQuery on the schema table using the given condition
func (*Schema[T]) DeleteAt ¶
DeleteAt performs a DeleteQuery on the given table using the given condition
func (*Schema[T]) DeleteTx ¶
DeleteTx performs a DeleteQuery as part of a transaction on the schema table using the given condition
func (*Schema[T]) DeleteTxAt ¶
DeleteTxAt performs a DeleteQuery as part of a transaction on the given table using the given condition
func (*Schema[T]) GetAllRows ¶
GetAllRows performs a SelectRowsQuery without condition at schema table
func (*Schema[T]) GetAllRowsAt ¶
GetAllRowsAt performs a SelectRowsQuery without condition at given table
func (*Schema[T]) GetAllRowsOnly ¶
GetAllRowsOnly performs a SelectRowsQuery without condition at schema table and prunes the items with given field names
func (*Schema[T]) GetAllRowsOnlyAt ¶
func (s *Schema[T]) GetAllRowsOnlyAt(rq *my.Request, table string, fieldNames ...string) ([]dict.Object, error)
GetAllRowsOnlyAt performs a SelectRowsQuery without condition at given table and prunes the items with given field names
func (*Schema[T]) GetAndLockTx ¶
func (s *Schema[T]) GetAndLockTx(rqtx *my.Request, lockField *bool, selectCondition qb.Condition, lockConditionFn func(T) qb.Condition) (T, error)
GetAndLockTx gets the item and locks it as part of a transaction Note: no need to include IsLocked = true/false in conditions, as this function adds it
func (*Schema[T]) GetAndLockTxItems ¶
func (s *Schema[T]) GetAndLockTxItems(rqtx *my.Request, lockField *bool, selectCondition qb.Condition, lockConditionFn func([]T) qb.Condition, numItems int) ([]T, error)
GetAndLockTxItems gets a list of items and locks all of them as part of a transaction Note: no need to include IsLocked = true/false in conditions, as this function adds it
func (*Schema[T]) GetOnly ¶
func (s *Schema[T]) GetOnly(rq *my.Request, condition qb.Condition, fieldNames ...string) (dict.Object, error)
GetOnly performs a SelectRowQuery at schema table and prunes the item with given field names
func (*Schema[T]) GetOnlyAt ¶
func (s *Schema[T]) GetOnlyAt(rq *my.Request, condition qb.Condition, table string, fieldNames ...string) (dict.Object, error)
GetOnlyAt performs a SelectRowQuery at given table and prunes the item with given field names
func (*Schema[T]) GetOrCreate ¶
func (s *Schema[T]) GetOrCreate(rq *my.Request, p *GetOrCreateParams[T]) (T, error)
GetOrCreate gets the item if it exists, otherwise creates and returns it
func (*Schema[T]) GetOrCreateAndLockTx ¶
func (s *Schema[T]) GetOrCreateAndLockTx(rqtx *my.Request, p *GetOrCreateAndLockParams[T]) (T, error)
GetOrCreateAndLockTx runs GetOrCreate and locks the item as part of a transaction Note: no need to include IsLocked = true/false in conditions, as this function adds it
func (*Schema[T]) GetOrCreateTx ¶
func (s *Schema[T]) GetOrCreateTx(rqtx *my.Request, p *GetOrCreateParams[T]) (T, error)
GetOrCreateTx gets the item if it exists, otherwise creates it as part of a transaction, and return the item
func (*Schema[T]) GetRowsOnly ¶
func (s *Schema[T]) GetRowsOnly(rq *my.Request, condition qb.Condition, fieldNames ...string) ([]dict.Object, error)
GetRowsOnly performs a SelectRowsQuery at schema table and prunes the items with given field names
func (*Schema[T]) GetRowsOnlyAt ¶
func (s *Schema[T]) GetRowsOnlyAt(rq *my.Request, condition qb.Condition, table string, fieldNames ...string) ([]dict.Object, error)
GetRowsOnlyAt performs a SelectRowsQuery at given table and prunes the items with given field names
func (*Schema[T]) InsertRows ¶
InsertRows performs an InsertRowsQuery at schema table
func (*Schema[T]) InsertRowsAt ¶
InsertRowsAt performs an InsertRowsQuery at given table
func (*Schema[T]) InsertTx ¶
InsertTx performs an InsertRowQuery as part of a transaction at schema table
func (*Schema[T]) InsertTxAt ¶
InsertTxAt performs an InsertRowQuery as part of a transaction at given table
func (*Schema[T]) InsertTxRows ¶
InsertTxRows performs an InsertRowsQuery as part of a transaction at schema table
func (*Schema[T]) InsertTxRowsAt ¶
InsertTxRowsAt performs an InsertRowsQuery as part of a transaction at given table
func (*Schema[T]) SetFlagAt ¶
func (s *Schema[T]) SetFlagAt(rq *my.Request, condition qb.Condition, field *bool, flag bool, table string) error
SetFlagAt updates the booleanField = flag at given table
func (*Schema[T]) SetFlags ¶
func (s *Schema[T]) SetFlags(rq *my.Request, condition qb.Condition, field *bool, flag bool, numItems int) error
SetFlags updates the booleanField = flag at schema table affecting multiple rows
func (*Schema[T]) SetFlagsAt ¶
func (s *Schema[T]) SetFlagsAt(rq *my.Request, condition qb.Condition, field *bool, flag bool, numItems int, table string) error
SetFlagsAt updates the booleanField = flag at given table affecting multiple rows
func (*Schema[T]) SetTxFlag ¶
func (s *Schema[T]) SetTxFlag(rqtx *my.Request, condition qb.Condition, field *bool, flag bool) error
SetTxFlag updates the booleanField = flag as part of transaction at schema table
func (*Schema[T]) SetTxFlagAt ¶
func (s *Schema[T]) SetTxFlagAt(rqtx *my.Request, condition qb.Condition, field *bool, flag bool, table string) error
SetTxFlagAt updates the booleanField = flag as part of transaction at given table
func (*Schema[T]) SetTxFlags ¶
func (s *Schema[T]) SetTxFlags(rqtx *my.Request, condition qb.Condition, field *bool, flag bool, numItems int) error
SetTxFlags updates the booleanField = flag as part of transaction at schema table affecting multiple rows
func (*Schema[T]) SetTxFlagsAt ¶
func (s *Schema[T]) SetTxFlagsAt(rqtx *my.Request, condition qb.Condition, field *bool, flag bool, numItems int, table string) error
SetTxFlagsAt updates the booleanField = flag as part of transaction at given table affecting multiple rows
func (*Schema[T]) Sum ¶
func (s *Schema[T]) Sum(rq *my.Request, columns []string, reader qb.RowReader[T], condition qb.Condition) (T, error)
Sum performs a SumQuery at schema table
func (*Schema[T]) SumAt ¶
func (s *Schema[T]) SumAt(rq *my.Request, columns []string, reader qb.RowReader[T], condition qb.Condition, table string) (T, error)
SumAt performs a SumQuery at the given table
func (*Schema[T]) ToggleCode ¶
func (s *Schema[T]) ToggleCode(rq *my.Request, code string, isActive bool, Items *Schema[Item]) error
ToggleCode toggles a row on/off using the given Code at the schema table
func (*Schema[T]) ToggleCodeAt ¶
func (s *Schema[T]) ToggleCodeAt(rq *my.Request, code string, isActive bool, table string, Items *Schema[Item]) error
ToggleCodeAt toggles a row on/off using the given Code at the given table
func (*Schema[T]) ToggleIDAt ¶
func (s *Schema[T]) ToggleIDAt(rq *my.Request, id ID, isActive bool, table string, Items *Schema[Item]) error
ToggleIDAt toggles a row on/off using the given ID at the given table
func (*Schema[T]) ToggleTxCode ¶
func (s *Schema[T]) ToggleTxCode(rqtx *my.Request, code string, isActive bool, Items *Schema[Item]) error
ToggleTxCode toggles a row on/off as part of a transaction using the given Code at the schema table
func (*Schema[T]) ToggleTxCodeAt ¶
func (s *Schema[T]) ToggleTxCodeAt(rqtx *my.Request, code string, isActive bool, table string, Items *Schema[Item]) error
ToggleTxCodeAt toggles a row on/off as part of a transaction using the given Code at the given table
func (*Schema[T]) ToggleTxID ¶
ToggleTxID toggles a row on/off as part of a transaction using the given ID at the schema table
func (*Schema[T]) ToggleTxIDAt ¶
func (s *Schema[T]) ToggleTxIDAt(rqtx *my.Request, id ID, isActive bool, table string, Items *Schema[Item]) error
ToggleTxIDAt toggles a row on/off as part of a transaction using the given ID at the given table
func (*Schema[T]) UpdateAndGetTx ¶
func (s *Schema[T]) UpdateAndGetTx(rqtx *my.Request, updateFn UpdateFn[T], updateCondition, selectCondition qb.Condition) (T, error)
UpdateAndGetTx updates one time and gets it as part of a transaction
func (*Schema[T]) UpdateAt ¶
func (s *Schema[T]) UpdateAt(rq *my.Request, updateFn UpdateFn[T], condition qb.Condition, table string) error
UpdateAt performs an UpdateQuery using UpdateFn at given table
func (*Schema[T]) UpdateFields ¶
func (s *Schema[T]) UpdateFields(rq *my.Request, updates qb.FieldUpdates, condition qb.Condition) error
UpdateFields performs an UpdateQuery using FieldUpdates at schema table
func (*Schema[T]) UpdateFieldsAt ¶
func (s *Schema[T]) UpdateFieldsAt(rq *my.Request, updates qb.FieldUpdates, condition qb.Condition, table string) error
UpdateFieldsAt performs an UpdateQuery using FieldUpdates at given table
func (*Schema[T]) UpdateTx ¶
UpdateTx performs an UpdateQuery using UpdateFn as part of a transaction at schema table
func (*Schema[T]) UpdateTxAt ¶
func (s *Schema[T]) UpdateTxAt(rqtx *my.Request, updateFn UpdateFn[T], condition qb.Condition, table string) error
UpdateTxAt performs an UpdateQuery using UpdateFn as part of a transaction at given table
func (*Schema[T]) UpdateTxFields ¶
func (s *Schema[T]) UpdateTxFields(rqtx *my.Request, updates qb.FieldUpdates, condition qb.Condition) error
UpdateTxFields performs an UpdateQuery as part of a transaction using FieldUpdates at schema table