Documentation ¶
Index ¶
- func ConvertSortParameters(params db.SortParameters, sortableColumns map[string]bool) []string
- func Open(ctx context.Context, options ...Option) (*sqlx.DB, error)
- func ToSnakeCase(in string) string
- type Default
- func (d *Default) Create(ctx context.Context, data interface{}) error
- func (d *Default) GetDBName() string
- func (d *Default) GetSession() interface{}
- func (d *Default) GetTableName() string
- func (d *Default) RemoveOne(ctx context.Context, filter interface{}) error
- func (d *Default) Search(ctx context.Context, filter interface{}, pagination *db.Pagination, ...) (int, error)
- func (d *Default) Update(ctx context.Context, updates map[string]interface{}, filter interface{}) error
- func (d *Default) WhereAndFetchOne(ctx context.Context, filter interface{}, result interface{}) error
- func (d *Default) WhereCount(ctx context.Context, filter interface{}) (int, error)
- type Option
- func WithConnMaxLifetime(t time.Duration) Option
- func WithDSN(dsn string) Option
- func WithDialect(dialect string) Option
- func WithLogLevel(logLevel string) Option
- func WithLogger(logger *zap.Logger) Option
- func WithMaxIdleConns(n int) Option
- func WithMaxOpenConns(n int) Option
- func WithOptions(options Options) Option
- func WithStatsRecordInterval(i time.Duration) Option
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertSortParameters ¶
func ConvertSortParameters(params db.SortParameters, sortableColumns map[string]bool) []string
ConvertSortParameters to sql query string
func ToSnakeCase ¶
ToSnakeCase convert the given string to snake case following the Golang format: acronyms are converted to lower-case and preceded by an underscore.
Types ¶
type Default ¶
type Default struct {
// contains filtered or unexported fields
}
Default contains the basic implementation of the SQL interface
func NewCRUDTable ¶
NewCRUDTable sets up a new Default struct
func (*Default) GetSession ¶
func (d *Default) GetSession() interface{}
GetSession returns the current session
func (*Default) GetTableName ¶
GetTableName returns table's name
func (*Default) RemoveOne ¶
RemoveOne is used to remove one element from the collection that match the filter
func (*Default) Search ¶
func (d *Default) Search(ctx context.Context, filter interface{}, pagination *db.Pagination, sortParams *db.SortParameters, results interface{}) (int, error)
Search for element in collection
func (*Default) Update ¶
func (d *Default) Update(ctx context.Context, updates map[string]interface{}, filter interface{}) error
Update the collection element with updates set matching the given filter
type Option ¶
type Option func(o *Options)
Option allows for managing configuration using functional options.
func WithConnMaxLifetime ¶
func WithDialect ¶
func WithLogLevel ¶
func WithLogger ¶
func WithMaxIdleConns ¶
func WithMaxOpenConns ¶
func WithOptions ¶
WithOptions sets database options through a single Options object