postgres

package
v0.0.0-...-58ae5d1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2022 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package postgres provides real connection to the PostgreSQL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PgxPoolIface

type PgxPoolIface interface {
	Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
	Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
	Ping(ctx context.Context) error
	Close()
}

PgxPoolIface defines a little interface for pgxpool functionality. Since in the real implementation we can use pgxpool.Pool, this interface exists mostly for testing purpose.

type Toggle

type Toggle struct {
	// contains filtered or unexported fields
}

Toggle is responsible to connect toggle entity with toggles table in PostgreSQL.

func NewToggle

func NewToggle(pool PgxPoolIface) *Toggle

NewToggle creates an instance of Toggle.

func (*Toggle) Delete

func (t *Toggle) Delete(ctx context.Context, key string) error

Delete deletes a toggle from PostgreSQL. If the group doesn't exist, it doesn't returns error.

func (*Toggle) GetAll

func (t *Toggle) GetAll(ctx context.Context, limit uint) ([]*entity.Toggle, error)

GetAll gets all available toggles from storage. If there isn't any toggle in repository, it returns empty list of toggle and nil error.

func (*Toggle) GetByKey

func (t *Toggle) GetByKey(ctx context.Context, key string) (*entity.Toggle, error)

GetByKey gets a toggle from database. It returns entity.ErrNotFound if toggle can't be found.

func (*Toggle) Insert

func (t *Toggle) Insert(ctx context.Context, toggle *entity.Toggle) error

Insert inserts the toggle into the toggles table.

func (*Toggle) UpdateIsEnabled

func (t *Toggle) UpdateIsEnabled(ctx context.Context, key string, value bool) error

UpdateIsEnabled updates the toggle's is_enabled value in the storage. It should handle if the toggle doesn't exist.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL