Documentation ¶
Overview ¶
Package db contains config related CRUD functionality.
Index ¶
- type Config
- type Store
- func (s Store) Create(ctx context.Context, config Config) error
- func (s Store) Delete(ctx context.Context, configKey string) error
- func (s Store) QueryByKey(ctx context.Context, configKey string) (Config, error)
- func (s Store) Tran(tx sqlx.ExtContext) Store
- func (s Store) Update(ctx context.Context, config Config) error
- func (s Store) WithinTran(ctx context.Context, fn func(sqlx.ExtContext) error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Key string `db:"key"` Value string `db:"value"` DateCreated time.Time `db:"date_created"` DateUpdated time.Time `db:"date_updated"` }
Config represent the structure we need for moving data between the app and the database.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages the set of APIs for config access.
func NewStore ¶
func NewStore(log *zap.SugaredLogger, db *sqlx.DB) Store
NewStore constructs a data for api access.
func (Store) QueryByKey ¶
QueryByKey gets the specified config from the database.
func (Store) Tran ¶
func (s Store) Tran(tx sqlx.ExtContext) Store
Tran return new Store with transaction in it.
func (Store) WithinTran ¶
WithinTran runs passed function and do commit/rollback at the end.
Click to show internal directories.
Click to hide internal directories.