Documentation
¶
Index ¶
- Variables
- type Alias
- type Argument
- type BaseRepositoryI
- type Column
- type Condition
- type Config
- type Connector
- type CursorPaginationParams
- type DTO
- type GDTO
- type GRepository
- type ID
- type Join
- type Logger
- type Obj
- type PagePaginationParams
- type PagePaginationResults
- type PlaceholderFormat
- type PureSqlxConnection
- type Query
- type Repository
- type SelectBuilder
- type Storage
- type Table
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidRepoEmptyRepo = errors.New("invalid repo (empty repo). Not registered?" + " Check this usage connector.AddAllowsRepos(repos ...db.Table)") ErrMismatchRowsCnt = errors.New("mismatch rows counts") ErrZeroPageSize = errors.New("zero value of params.PageSize") ErrZeroLimitSize = errors.New("zero value of params.Limit") )
Functions ¶
This section is empty.
Types ¶
type BaseRepositoryI ¶
type BaseRepositoryI interface {
Name() Table // Name of table/repo (repo obj)
GetRowsByQuery(ctx context.Context, qb SelectBuilder) (*sql.Rows, error)
CountByQuery(ctx context.Context, qb SelectBuilder) (uint64, error)
Insert(context.Context, []Column, []Argument) (int64, error)
UpdateCustom(context.Context, map[string]any, Condition) (int64, error)
}
BaseRepositoryI - base method for all type Repo's
type Config ¶
type Config = interface {
IsEnableValidationRepoNames() bool
IsEnableReposCache() bool
PlaceholderFormat() PlaceholderFormat // squirrel int code for placeholder
}
Config - configuration obj for Storage
type Connector ¶
type Connector[C Config] interface { Config() C AddAllowsRepos(...Table) GetAllowsRepos() []Table IsAllowRepo(Table) bool Logger() Logger Connection() PureSqlxConnection Repo(DTO) Repository // TODO think about -> optional.Optional[Repository] RepoByName(Table) Repository AutoCreate(context.Context, DTO) (int64, error) AutoGet(context.Context, DTO) error AutoUpdate(context.Context, DTO) (int64, error) AutoDelete(context.Context, DTO) (int64, error) }
Connector - entity for describe connection to specific DB instance
type CursorPaginationParams ¶
type GRepository ¶
type GRepository[I ID, D DTO] interface { BaseRepositoryI Create(context.Context, D) (I, error) Get(context.Context, I) (D, error) Update(context.Context, I, D) (int64, error) Delete(context.Context, I) (int64, error) FindBy(context.Context, []Column, Condition) ([]D, error) FindOneBy(context.Context, []Column, Condition) (D, error) Select(context.Context, SelectBuilder) ([]D, error) SelectWithPagePagination(context.Context, SelectBuilder, PagePaginationParams) ([]D, PagePaginationResults, error) SelectWithCursorOnPKPagination(context.Context, SelectBuilder, CursorPaginationParams) ([]D, error) }
GRepository - methods for new (modern) approach generic based Repo's
type PagePaginationParams ¶
type PagePaginationResults ¶
type PlaceholderFormat ¶
type PlaceholderFormat = squirrel.PlaceholderFormat
PlaceholderFormat - squirrel.PlaceholderFormat
type PureSqlxConnection ¶
type PureSqlxConnection interface {
sqlx.QueryerContext
sqlx.ExecerContext
sqlx.ExtContext
sqlx.PreparerContext
transaction.TxxI
}
type Repository ¶
type Repository interface {
BaseRepositoryI
Create(context.Context, any) (int64, error) // todo add one method for ID = string or move to generics API only
Get(context.Context, ID, any) error
Update(context.Context, ID, any) (int64, error)
Delete(context.Context, ID) (int64, error)
FindBy(context.Context, []Column, Condition, any) error
FindOneBy(context.Context, []Column, Condition, any) error
FindByWithInnerJoin(context.Context, []Column, Alias, Join, Condition, any) error
FindOneByWithInnerJoin(context.Context, []Column, Alias, Join, Condition, any) error
Select(context.Context, SelectBuilder, any) error
SelectWithPagePagination(context.Context, SelectBuilder, PagePaginationParams, any) (PagePaginationResults, error)
SelectWithCursorOnPKPagination(context.Context, SelectBuilder, CursorPaginationParams, any) error
}
Repository - methods for classic Repo's (non generics)
type SelectBuilder ¶
type SelectBuilder = squirrel.SelectBuilder
SelectBuilder - squirrel.SelectBuilder
type Storage ¶
type Storage[C Config] interface { Config() C Connect() error Reconnect() error OnConnect(context.Context, func()) error // actions that will be performed after function call Connect() OnReconnect(context.Context, func()) error // actions that will be performed after function call Reconnect() OnStop(context.Context, func()) error // actions that will be performed after function call Close() Master() Connector[C] Slaves() []Connector[C] Close() error }
Storage - abstract Storage interface general storage interface.
Click to show internal directories.
Click to hide internal directories.