Documentation ¶
Overview ¶
Package persistence defines the framework to interact with the database storage.
Index ¶
- Constants
- func IsAlreadyExists(err error) bool
- func IsCanNotBeginTransaction(err error) bool
- func IsCanNotCommitTransaction(err error) bool
- func IsCanNotRollbackTransaction(err error) bool
- func IsConfigCanNotBeLoaded(err error) bool
- func IsDBResponseCouldNotBeProcessed(err error) bool
- func IsEntryNotAdded(err error) bool
- func IsNotFound(err error) bool
- func IsPermanentConnectionError(err error) bool
- func IsStatementCouldNotBePrepared(err error) bool
- func IsStatementExecutionFailed(err error) bool
- func IsTransientConnectionError(err error) bool
- func IsTxNotInContext(err error) bool
- type BetweenFilter
- type EqualFilter
- type Error
- func NewAlreadyExistsError() *Error
- func NewCanNotBeginTransactionError() *Error
- func NewCanNotCommitTransactionError() *Error
- func NewCanNotRollbackTransactionError() *Error
- func NewConfigCanNotBeLoadedError() *Error
- func NewDBResponseCanNotBeProcessedError() *Error
- func NewEntryNotAddedError() *Error
- func NewNotFoundError() *Error
- func NewPermanentConnectionError() *Error
- func NewStatementCouldNotBePreparedError() *Error
- func NewStatementExecutionFailedError() *Error
- func NewTransientConnectionError() *Error
- func NewTxNotInContextError() *Error
- type ExecuteStmtWithStorageResultOutput
- type Filter
- type FilterGroup
- type FilterOption
- type GreaterFilter
- type GreaterOrEqualFilter
- type LessFilter
- type LessOrEqualFilter
- type ListEqualFilter
- type MapperConfig
- type Order
- type OrderByOption
- type OrderDirection
- type Pagination
- type ReadDirAndFileFS
- type StatementConfig
- type Storage
- type StorageConfig
- type StorageConfigOptions
Constants ¶
const ( // Asc ascendant direction order Asc OrderDirection = "asc" // Desc descendant direction order Desc OrderDirection = "desc" // CreationDate creation date order CreationDate OrderByOption = "creation_date" // LastUpdate update date order LastUpdate OrderByOption = "last_update" )
Variables ¶
This section is empty.
Functions ¶
func IsAlreadyExists ¶
func IsConfigCanNotBeLoaded ¶
func IsEntryNotAdded ¶
func IsNotFound ¶
func IsTxNotInContext ¶
Types ¶
type BetweenFilter ¶
BetweenFilter to filter by the specified field between two values
func (BetweenFilter) ToSQLStmt ¶
func (f BetweenFilter) ToSQLStmt() string
ToSQLStmt SQL statement for the filter
type EqualFilter ¶
type EqualFilter struct {
By string
}
EqualFilter to filter by the specified field with equal value
func (EqualFilter) ToSQLStmt ¶
func (f EqualFilter) ToSQLStmt() string
ToSQLStmt SQL statement for the filter
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error for the persistence framework
func NewAlreadyExistsError ¶
func NewAlreadyExistsError() *Error
func NewCanNotBeginTransactionError ¶
func NewCanNotBeginTransactionError() *Error
func NewCanNotCommitTransactionError ¶
func NewCanNotCommitTransactionError() *Error
func NewCanNotRollbackTransactionError ¶
func NewCanNotRollbackTransactionError() *Error
func NewConfigCanNotBeLoadedError ¶
func NewConfigCanNotBeLoadedError() *Error
func NewDBResponseCanNotBeProcessedError ¶
func NewDBResponseCanNotBeProcessedError() *Error
func NewEntryNotAddedError ¶
func NewEntryNotAddedError() *Error
func NewNotFoundError ¶
func NewNotFoundError() *Error
func NewPermanentConnectionError ¶
func NewPermanentConnectionError() *Error
func NewStatementCouldNotBePreparedError ¶
func NewStatementCouldNotBePreparedError() *Error
func NewStatementExecutionFailedError ¶
func NewStatementExecutionFailedError() *Error
func NewTransientConnectionError ¶
func NewTransientConnectionError() *Error
func NewTxNotInContextError ¶
func NewTxNotInContextError() *Error
func (*Error) WithMessage ¶
type ExecuteStmtWithStorageResultOutput ¶
ExecuteStmtWithStorageResultOutput wraps the result of an statement
type Filter ¶
type Filter interface { // ToSQLStmt SQL statement for the filter ToSQLStmt() string }
Filter defines the functionality to convert filters into statements
type FilterGroup ¶
type FilterGroup struct {
Filters []Filter
}
FilterGroup defines the group of filters Storage data
type GreaterFilter ¶
type GreaterFilter struct {
By string
}
GreaterFilter to filter by the specified field with greater value
func (GreaterFilter) ToSQLStmt ¶
func (f GreaterFilter) ToSQLStmt() string
ToSQLStmt SQL statement for the filter
type GreaterOrEqualFilter ¶
type GreaterOrEqualFilter struct {
By string
}
GreaterOrEqualFilter to filter by the specified field with greater or equal value
func (GreaterOrEqualFilter) ToSQLStmt ¶
func (f GreaterOrEqualFilter) ToSQLStmt() string
ToSQLStmt SQL statement for the filter
type LessFilter ¶
type LessFilter struct {
By string
}
LessFilter to filter by the specified field with less value
func (LessFilter) ToSQLStmt ¶
func (f LessFilter) ToSQLStmt() string
ToSQLStmt SQL statement for the filter
type LessOrEqualFilter ¶
type LessOrEqualFilter struct {
By string
}
LessOrEqualFilter to filter by the specified field with less or equal value
func (LessOrEqualFilter) ToSQLStmt ¶
func (f LessOrEqualFilter) ToSQLStmt() string
ToSQLStmt SQL statement for the filter
type ListEqualFilter ¶
ListEqualFilter to filter by the specified field with a list of possible value
func (ListEqualFilter) ToSQLStmt ¶
func (f ListEqualFilter) ToSQLStmt() string
ToSQLStmt SQL statement for the filter
type MapperConfig ¶
type MapperConfig struct { ID string `xml:"id,attr"` Statements []StatementConfig `xml:"statement"` }
MapperConfig identifies a mapper configuration for a set of StatementConfig
type Order ¶
type Order struct { By OrderByOption `valid:"required"` Direction OrderDirection `valid:"required"` }
Order defines order on Storage data
type Pagination ¶
type Pagination struct { // Limit maximum number of entries to return Limit int `valid:"required"` // Offset zero-based offset of the first item in the collection to return Offset int `valid:"required"` }
Pagination from the Storage data with limit/offset navigation
type ReadDirAndFileFS ¶
type ReadDirAndFileFS interface { fs.ReadDirFS fs.ReadFileFS }
type StatementConfig ¶
StatementConfig identifies a statement configuration
type Storage ¶
type Storage interface { // QueryAll obtains all element from statement with arguments provided. It returns an error if it fails QueryAll(ctx context.Context, stmtID string, args interface{}, dst interface{}) error // ExecuteStmt executes statement with arguments provided. It returns an error if it fails ExecuteStmt(ctx context.Context, stmtID string, args interface{}) error // ExecuteStmtWithStorageResult executes statement with arguments provided. It returns information on stmt or an error if it fails ExecuteStmtWithStorageResult(ctx context.Context, stmtID string, args interface{}) (*ExecuteStmtWithStorageResultOutput, error) // BeginTransaction starts a Storage operation that is transactional. It returns an error if it fails BeginTransaction(ctx context.Context) (context.Context, error) // RollbackTransaction rollbacks to previous state a Storage operation that is transactional. It returns an error if it fails RollbackTransaction(ctx context.Context) error // CommitTransaction confirms a Storage operation that is transactional. It returns an error if it fails CommitTransaction(ctx context.Context) error // GetTransaction returns the transaction from context (in case of success). GetTransaction(ctx context.Context) (any, error) // AddConfig registers SQL statements AddConfig(config StorageConfig) error }
type StorageConfig ¶
type StorageConfig struct {
// contains filtered or unexported fields
}
StorageConfig configuration for StatementConfig
func NewEmptyStorageConfig ¶
func NewEmptyStorageConfig() StorageConfig
NewEmptyStorageConfig returns an empty StorageConfig
func NewStorageConfig ¶
func NewStorageConfig(options StorageConfigOptions) (*StorageConfig, error)
NewStorageConfig returns a new StorageConfig with the provided configuration options.
func (*StorageConfig) AddConfig ¶
func (config *StorageConfig) AddConfig(newFwConfig StorageConfig) error
AddConfig adds a new configuration to the configurations data map.
func (*StorageConfig) GetStatement ¶
func (config *StorageConfig) GetStatement(id string) (StatementConfig, bool)
GetStatement obtain the StatementConfig with the AdminID provided
type StorageConfigOptions ¶
type StorageConfigOptions struct { ReadDirAndFileFS ReadDirAndFileFS MappersPath string Driver string }
Directories ¶
Path | Synopsis |
---|---|
Package dbmigrator defines the functionalities for database migrations.
|
Package dbmigrator defines the functionalities for database migrations. |
Package sql defines the SQL database management utilities.
|
Package sql defines the SQL database management utilities. |
postgres
Package postgres defines the PostgresSQL functionalities.
|
Package postgres defines the PostgresSQL functionalities. |
sqlite
Package sqlite defines the SQLite database functionality to operate with.
|
Package sqlite defines the SQLite database functionality to operate with. |