Documentation ¶
Index ¶
- Constants
- Variables
- func AddSearchTerm(base squirrel.SelectBuilder, q string, columns ...string) squirrel.SelectBuilder
- func ApplyDefaultSorting(opts model.Sorter, base squirrel.SelectBuilder, defaultSort string) squirrel.SelectBuilder
- func ApplyPaging(page int, size int, base squirrel.SelectBuilder) squirrel.SelectBuilder
- func BindNamed(query string, params map[string]interface{}) (string, []interface{}, error)
- func CompactSQL(s string) string
- func FormAsCTE(in squirrel.Sqlizer, alias string) (string, []any, error)
- func FormAsCTEs(in map[string]squirrel.Sqlizer) (string, []any, error)
- func ParseSearchTerm(q string) (s string, operator string)
- func PrepareSearchNumber(number string) string
- func ResolvePaging[T any](size int, items []*T) (updatedItems []*T, next bool)
- type AccessControlStore
- type CaseCommentStore
- type CaseFileStore
- type CaseLinkStore
- type CaseStore
- type CatalogStore
- type CloseReasonGroupStore
- type CloseReasonStore
- type PriorityStore
- type SLAConditionStore
- type SLAStore
- type ServiceStore
- type SourceStore
- type StatusConditionStore
- type StatusStore
- type Store
- type Transaction
- type TxManager
- func (m *TxManager) Commit(ctx context.Context) error
- func (m *TxManager) Exec(ctx context.Context, sql string, args ...interface{}) (pgconn.CommandTag, error)
- func (m *TxManager) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
- func (m *TxManager) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
- func (m *TxManager) Rollback(ctx context.Context) error
Constants ¶
const ( ComparisonILike = "ilike" ComparisonRegexp = "~" )
Variables ¶
var Ident = func(left, right string) string { return fmt.Sprintf("%s.%s", left, right) }
Ident returns a string that represents a qualified identifier. For example, Ident("cc", "case_link") returns "cc.case_link".
Functions ¶
func AddSearchTerm ¶
func AddSearchTerm(base squirrel.SelectBuilder, q string, columns ...string) squirrel.SelectBuilder
func ApplyDefaultSorting ¶
func ApplyDefaultSorting(opts model.Sorter, base squirrel.SelectBuilder, defaultSort string) squirrel.SelectBuilder
func ApplyPaging ¶
func ApplyPaging(page int, size int, base squirrel.SelectBuilder) squirrel.SelectBuilder
func CompactSQL ¶
CompactSQL formats given SQL text to compact form. - replaces consecutive white-space(s) with single SPACE(' ') - suppress single-line comment(s), started with -- up to [E]nd[o]f[L]ine - suppress multi-line comment(s), enclosed into /* ... */ pairs - transmits literal '..' or ".." sources in their original form https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-OPERATORS
func ParseSearchTerm ¶
ParseSearchTerm delimit searches for the regexp search indicators and if found returns string without indicators and indicator that regexp search found. Returns changed copy of the input slice.
func PrepareSearchNumber ¶
PrepareSearchNumber reverses the first string
func ResolvePaging ¶
Types ¶
type AccessControlStore ¶
type AccessControlStore interface { // Check if user has Rbac access RbacAccess(ctx context.Context, domainId, id int64, groups []int, access uint8, table string) (bool, error) }
------------Access Control------------//
type CaseCommentStore ¶
type CaseCommentStore interface { // Create comment Publish(rpc *model.CreateOptions, add *_go.CaseComment) (*_go.CaseComment, error) // List comments List(rpc *model.SearchOptions) (*_go.CaseCommentList, error) // Update comment Update(req *model.UpdateOptions, upd *_go.CaseComment) (*_go.CaseComment, error) // Delete comment Delete(req *model.DeleteOptions) error }
Comments attribute attached to the case (n:1)
type CaseFileStore ¶
type CaseFileStore interface { // List files List(rpc *model.SearchOptions) (*_go.CaseFileList, error) }
type CaseLinkStore ¶
type CaseLinkStore interface { // Create link Create(rpc *model.CreateOptions, add *_go.InputCaseLink) (*_go.CaseLink, error) // List links List(rpc *model.SearchOptions) (*_go.CaseLinkList, error) // Update link Update(req *model.UpdateOptions, upd *_go.InputCaseLink) (*_go.CaseLink, error) // Delete link Delete(req *model.DeleteOptions) error }
RelatedCases attribute attached to the case (n:1)
type CaseStore ¶
type CaseStore interface { // Create a new case Create(rpc *model.CreateOptions, add *_go.Case) (*_go.Case, error) // List cases List(rpc *model.SearchOptions) (*_go.CaseList, error) // Update case Update(req *model.UpdateOptions, upd *_go.Case) (*_go.Case, error) // Delete case Delete(req *model.DeleteOptions) error }
------------ Cases Stores ------------ //
type CatalogStore ¶
type CatalogStore interface { // Create a new catalog Create(rpc *model.CreateOptions, add *_go.Catalog) (*_go.Catalog, error) // List catalogs List(rpc *model.SearchOptions, depth int64, fetchType *_go.FetchType) (*_go.CatalogList, error) // Delete catalog Delete(rpc *model.DeleteOptions) error // Update catalog Update(rpc *model.UpdateOptions, lookup *_go.Catalog) (*_go.Catalog, error) }
CatalogStore is parent store managing service catalogs.
type CloseReasonGroupStore ¶
type CloseReasonGroupStore interface { // Create a new close reason lookup Create(rpc *model.CreateOptions, add *_go.CloseReasonGroup) (*_go.CloseReasonGroup, error) // List close reason lookup List(rpc *model.SearchOptions) (*_go.CloseReasonGroupList, error) // Delete close reason lookup Delete(rpc *model.DeleteOptions) error // Update close reason lookup Update(rpc *model.UpdateOptions, lookup *_go.CloseReasonGroup) (*_go.CloseReasonGroup, error) }
type CloseReasonStore ¶
type CloseReasonStore interface { // Create a new reason Create(ctx *model.CreateOptions, add *_go.CloseReason) (*_go.CloseReason, error) // List reasons List(ctx *model.SearchOptions, closeReasonId int64) (*_go.CloseReasonList, error) // Delete reason Delete(ctx *model.DeleteOptions, closeReasonId int64) error // Update reason Update(ctx *model.UpdateOptions, lookup *_go.CloseReason) (*_go.CloseReason, error) }
type PriorityStore ¶
type PriorityStore interface { // Create a new priority lookup Create(rpc *model.CreateOptions, add *_go.Priority) (*_go.Priority, error) // List priority lookup List(rpc *model.SearchOptions) (*_go.PriorityList, error) // Delete priority lookup Delete(rpc *model.DeleteOptions) error // Update priority lookup Update(rpc *model.UpdateOptions, lookup *_go.Priority) (*_go.Priority, error) }
type SLAConditionStore ¶
type SLAConditionStore interface { // Create a new SLA сondition Create(ctx *model.CreateOptions, add *_go.SLACondition, priorities []int64) (*_go.SLACondition, error) // List SLA сondition List(ctx *model.SearchOptions) (*_go.SLAConditionList, error) // Delete SLA сondition Delete(ctx *model.DeleteOptions) error // Update SLA сondition Update(ctx *model.UpdateOptions, lookup *_go.SLACondition) (*_go.SLACondition, error) }
type SLAStore ¶
type SLAStore interface { // Create a new SLA lookup Create(rpc *model.CreateOptions, add *_go.SLA) (*_go.SLA, error) // List SLA lookup List(rpc *model.SearchOptions) (*_go.SLAList, error) // Delete SLA lookup Delete(rpc *model.DeleteOptions) error // Update SLA lookup Update(rpc *model.UpdateOptions, lookup *_go.SLA) (*_go.SLA, error) }
type ServiceStore ¶
type ServiceStore interface { // Create a new service Create(rpc *model.CreateOptions, add *_go.Service) (*_go.Service, error) // List services List(rpc *model.SearchOptions) (*_go.ServiceList, error) // Delete service Delete(rpc *model.DeleteOptions) error // Update service Update(rpc *model.UpdateOptions, lookup *_go.Service) (*_go.Service, error) }
Service is child store managing services within catalogs.
type SourceStore ¶
type SourceStore interface { // Create a new source lookup Create(rpc *model.CreateOptions, add *_go.Source) (*_go.Source, error) // List source lookup List(rpc *model.SearchOptions) (*_go.SourceList, error) // Delete source lookup Delete(rpc *model.DeleteOptions) error // Update source lookup Update(rpc *model.UpdateOptions, lookup *_go.Source) (*_go.Source, error) }
type StatusConditionStore ¶
type StatusConditionStore interface { // Create a new status сondition Create(ctx *model.CreateOptions, add *_go.StatusCondition) (*_go.StatusCondition, error) // List status сondition List(ctx *model.SearchOptions, statusId int64) (*_go.StatusConditionList, error) // Delete status сondition Delete(ctx *model.DeleteOptions, statusId int64) error // Update status сondition Update(ctx *model.UpdateOptions, status *_go.StatusCondition) (*_go.StatusCondition, error) }
type StatusStore ¶
type StatusStore interface { // Create a new status lookup Create(rpc *model.CreateOptions, add *_go.Status) (*_go.Status, error) // List status lookup List(rpc *model.SearchOptions) (*_go.StatusList, error) // Delete status lookup Delete(rpc *model.DeleteOptions) error // Update status lookup Update(rpc *model.UpdateOptions, lookup *_go.Status) (*_go.Status, error) }
------------ Dictionary Stores ------------ //
type Store ¶
type Store interface { // ------------ Cases Stores ------------ // Case() CaseStore CaseComment() CaseCommentStore CaseLink() CaseLinkStore CaseFile() CaseFileStore // ------------ Dictionary Stores ------------ // Source() SourceStore Priority() PriorityStore // ------------ Closure reasons Stores ------------ // CloseReasonGroup() CloseReasonGroupStore CloseReason() CloseReasonStore // ------------ Status ------------ // Status() StatusStore StatusCondition() StatusConditionStore // ------------ SLA Stores ------------ // SLA() SLAStore SLACondition() SLAConditionStore // ------------ Catalog and Service Stores ------------ // Catalog() CatalogStore Service() ServiceStore // ------------ Access Control ------------ // AccessControl() AccessControlStore // ------------ Database Management ------------ // Database() (*pgxpool.Pool, *dberr.DBError) // Return custom DB error Open() *dberr.DBError // Return custom DB error Close() *dberr.DBError // Return custom DB error }
type Transaction ¶
type Transaction interface { Commit(ctx context.Context) error Rollback(ctx context.Context) error QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error) Exec(ctx context.Context, sql string, args ...interface{}) (pgconn.CommandTag, error) }
Transaction defines the interface for handling transactions.
type TxManager ¶
type TxManager struct {
// contains filtered or unexported fields
}
TxManager provides a concrete implementation of the Transaction interface.
func NewTxManager ¶
func NewTxManager(tx pgx.Tx) *TxManager
NewTxManager creates a new transaction manager from an existing pgx.Tx.
func (*TxManager) Exec ¶
func (m *TxManager) Exec(ctx context.Context, sql string, args ...interface{}) (pgconn.CommandTag, error)
Exec executes a query that doesn't return rows and returns a CommandTag.