postgres

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2022 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TestConnStringEnvVar = "PG_TEST_DB"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

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

func NewFactory

func NewFactory(db *sql.DB) *Factory

func (*Factory) NewStorer

func (f *Factory) NewStorer(ctx context.Context) (scopes.Storer, error)

func (*Factory) TeardownStorers

func (f *Factory) TeardownStorers() error

type Scope

type Scope struct {
	ID               string               `sql_column:"id"`
	UserPolicy       string               `sql_column:"user_policy"`
	UserExceptions   pqarrays.StringArray `sql_column:"user_exceptions"`
	ClientPolicy     string               `sql_column:"client_policy"`
	ClientExceptions pqarrays.StringArray `sql_column:"client_exceptions"`
	IsDefault        bool                 `sql_column:"is_default"`
}

func (Scope) GetSQLTableName

func (s Scope) GetSQLTableName() string

type Storer

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

Storer is an implementation of the Storer interface that stores data in a PostgreSQL database.

func NewStorer

func NewStorer(ctx context.Context, conn *sql.DB) *Storer

NewStorer returns a Storer instance that is backed by the specified *sql.DB. The returned Storer instance is ready to be used as a Storer.

func (*Storer) Create

func (s *Storer) Create(ctx context.Context, scope scopes.Scope) error

Create inserts the passed Scope into the database, returning an ErrScopeAlreadyExists error if a Scope with the same ID already exists in the database.

func (*Storer) Delete

func (s *Storer) Delete(ctx context.Context, id string) error

Delete removes the Scope that matches the specified ID from the Memstore, if any Scope matches the specified ID in the Memstore.

func (*Storer) GetMulti

func (s *Storer) GetMulti(ctx context.Context, ids []string) (map[string]scopes.Scope, error)

GetMulti retrieves the Scopes specified by the passed IDs from the database, returning an empty map if no matching Scopes are found. If a Scope is not found, no error will be returned, it will just be omitted from the map.

func (*Storer) ListDefault

func (s *Storer) ListDefault(ctx context.Context) ([]scopes.Scope, error)

ListDefault returns all the Scopes with IsDefault set to true. sorted lexicographically by their ID.

func (*Storer) Update

func (s *Storer) Update(ctx context.Context, id string, change scopes.Change) error

Update applies the passed Change to the Scope that matches the specified ID in the Memstore, if any Scope matches the specified ID in the Memstore.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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