Documentation
¶
Index ¶
- func Migrate(ctx context.Context, db *sqlx.DB, migrations []Migration, ...) error
- func Open(dsn string, options ...OpenOption) (*sqlx.DB, error)
- func RerunLastMigration(ctx context.Context, db *sqlx.DB, migrations []Migration, ...) error
- type Hook
- type HookAfterPut
- type HookBeforePut
- type Hooks
- type MigrateOption
- type Migration
- type MissingKeyError
- type OpenOption
- type Query
- type RepoConfig
- type RepoGeneric
- func (repo *RepoGeneric[T]) BeginTx(ctx context.Context) (*Tx[T], error)
- func (repo *RepoGeneric[T]) Count(ctx context.Context) (int64, error)
- func (repo *RepoGeneric[T]) Delete(ctx context.Context, model *T) error
- func (repo *RepoGeneric[T]) DeleteKey(ctx context.Context, key string) error
- func (repo *RepoGeneric[T]) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (repo *RepoGeneric[T]) Exists(ctx context.Context, key string) (bool, error)
- func (repo *RepoGeneric[T]) ExistsQuery() *Query[bool]
- func (repo *RepoGeneric[T]) Get(ctx context.Context, key string) (*T, error)
- func (repo *RepoGeneric[T]) GetMulti(ctx context.Context, keys []string) ([]*T, error)
- func (repo *RepoGeneric[T]) List(ctx context.Context) ([]*T, error)
- func (repo *RepoGeneric[T]) Put(ctx context.Context, model *T) error
- func (repo *RepoGeneric[T]) Query(ctx context.Context, query string, args ...interface{}) (*T, error)
- func (repo *RepoGeneric[T]) QueryList(ctx context.Context, query string, args ...interface{}) ([]*T, error)
- func (repo *RepoGeneric[T]) QueryMap(ctx context.Context, query string, args ...interface{}) (map[string]*T, error)
- type RepoSingleton
- func (repo *RepoSingleton[T]) BeginTx(ctx context.Context) (*Tx[T], error)
- func (repo *RepoSingleton[T]) Exists(ctx context.Context, key string) (bool, error)
- func (repo *RepoSingleton[T]) Get(ctx context.Context, key string) (*T, error)
- func (repo *RepoSingleton[T]) List(ctx context.Context) ([]*T, error)
- func (repo *RepoSingleton[T]) Put(ctx context.Context, model *T) error
- func (repo *RepoSingleton[T]) Query(ctx context.Context, query string, args ...interface{}) (*T, error)
- func (repo *RepoSingleton[T]) QueryList(ctx context.Context, query string, args ...interface{}) ([]*T, error)
- type Tx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Migrate ¶ added in v0.10.0
func Migrate(ctx context.Context, db *sqlx.DB, migrations []Migration, options ...MigrateOption) error
Migrate runs migrations from the list that have not been yet executed.
func RerunLastMigration ¶ added in v0.10.0
func RerunLastMigration(ctx context.Context, db *sqlx.DB, migrations []Migration, options ...MigrateOption) error
RerunLastMigration runs the last migration in the list.
Types ¶
type HookAfterPut ¶ added in v0.7.2
type HookBeforePut ¶ added in v0.7.2
type MigrateOption ¶ added in v0.11.0
type MigrateOption func(opts *migrateOptions)
func WithMigrateLogger ¶ added in v0.11.0
func WithMigrateLogger(logger *slog.Logger) MigrateOption
type Migration ¶ added in v0.10.0
Migration is the function that will be run to execute the migration operation in the database.
type MissingKeyError ¶ added in v0.9.0
type MissingKeyError struct {
Key string
}
func (MissingKeyError) Error ¶ added in v0.9.0
func (e MissingKeyError) Error() string
type OpenOption ¶ added in v0.9.0
type OpenOption func(opts *openOptions)
func WithDriver ¶ added in v0.9.0
func WithDriver(driverName string) OpenOption
func WithLogger ¶ added in v0.9.3
func WithLogger(logger *slog.Logger) OpenOption
type Query ¶ added in v0.6.0
type Query[T any] struct { // contains filtered or unexported fields }
type RepoConfig ¶
type RepoGeneric ¶
type RepoGeneric[T any] struct { // contains filtered or unexported fields }
func NewRepoGeneric ¶
func NewRepoGeneric[T any](db *sqlx.DB, cnf RepoConfig[T]) *RepoGeneric[T]
func (*RepoGeneric[T]) BeginTx ¶ added in v0.7.1
func (repo *RepoGeneric[T]) BeginTx(ctx context.Context) (*Tx[T], error)
func (*RepoGeneric[T]) Count ¶
func (repo *RepoGeneric[T]) Count(ctx context.Context) (int64, error)
func (*RepoGeneric[T]) Delete ¶ added in v0.2.0
func (repo *RepoGeneric[T]) Delete(ctx context.Context, model *T) error
func (*RepoGeneric[T]) DeleteKey ¶ added in v0.2.0
func (repo *RepoGeneric[T]) DeleteKey(ctx context.Context, key string) error
func (*RepoGeneric[T]) ExistsQuery ¶ added in v0.6.0
func (repo *RepoGeneric[T]) ExistsQuery() *Query[bool]
func (*RepoGeneric[T]) Get ¶
func (repo *RepoGeneric[T]) Get(ctx context.Context, key string) (*T, error)
func (*RepoGeneric[T]) GetMulti ¶
func (repo *RepoGeneric[T]) GetMulti(ctx context.Context, keys []string) ([]*T, error)
func (*RepoGeneric[T]) Query ¶
func (repo *RepoGeneric[T]) Query(ctx context.Context, query string, args ...interface{}) (*T, error)
type RepoSingleton ¶
type RepoSingleton[T any] struct { // contains filtered or unexported fields }
func NewRepoSingleton ¶
func NewRepoSingleton[T any](db *sqlx.DB, cnf RepoConfig[T]) *RepoSingleton[T]
func (*RepoSingleton[T]) BeginTx ¶ added in v0.7.1
func (repo *RepoSingleton[T]) BeginTx(ctx context.Context) (*Tx[T], error)
func (*RepoSingleton[T]) Get ¶
func (repo *RepoSingleton[T]) Get(ctx context.Context, key string) (*T, error)
func (*RepoSingleton[T]) List ¶ added in v0.8.0
func (repo *RepoSingleton[T]) List(ctx context.Context) ([]*T, error)
func (*RepoSingleton[T]) Put ¶
func (repo *RepoSingleton[T]) Put(ctx context.Context, model *T) error
Click to show internal directories.
Click to hide internal directories.