postgres

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2021 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package postgres provides a store implementation using Postgres.

Index

Constants

View Source
const (
	// DefaultSQLMaxOpenConns is the default maximum number of open connections.
	DefaultSQLMaxOpenConns = 100
)

Variables

This section is empty.

Functions

func Filter

func Filter() datastore.Filter

func IsIntegrityConstraintViolation

func IsIntegrityConstraintViolation(err error) bool

IsIntegrityConstraintViolation checks if the error is an integrity constraint violation.

func NewCursor

func NewCursor(rows pgx.Rows) datastore.Cursor

NewCursor constructs a new cursor instance.

Types

type Add

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

Add is an instance of the add repository command using Postgres.

func NewAdd

func NewAdd(store *Store) *Add

NewAdd creates a new add command for the Postgres database.

func (*Add) Execute

func (a *Add) Execute(ctx context.Context) (int, error)

func (*Add) Item

func (a *Add) Item(snapshot map[string]interface{}) datastore.Add

func (*Add) Query

func (a *Add) Query(q datastore.Query) datastore.Add

func (*Add) Statement

func (a *Add) Statement() (string, []interface{}, error)

func (*Add) To

func (a *Add) To(collection string) datastore.Add

type Cursor

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

Cursor represents an instance of a Cursor

func (*Cursor) Close

func (c *Cursor) Close()

func (*Cursor) Decode

func (c *Cursor) Decode(values ...interface{}) error

func (*Cursor) Error

func (c *Cursor) Error() error

func (*Cursor) Next

func (c *Cursor) Next() bool

type GooseLogger

type GooseLogger struct{}

GooseLogger is a custom logger for the goose package

func NewGooseLogger

func NewGooseLogger() *GooseLogger

NewGooseLogger creates a new goose logger

func (*GooseLogger) Fatal

func (g *GooseLogger) Fatal(v ...interface{})

func (*GooseLogger) Fatalf

func (g *GooseLogger) Fatalf(format string, v ...interface{})

func (*GooseLogger) Print

func (g *GooseLogger) Print(v ...interface{})

func (*GooseLogger) Printf

func (g *GooseLogger) Printf(format string, v ...interface{})

func (*GooseLogger) Println

func (g *GooseLogger) Println(v ...interface{})

type PGXLogger

type PGXLogger struct{}

PGXLogger is an instance of the pgx Logger

func NewPGXLogger

func NewPGXLogger() *PGXLogger

NewPGXLogger creates a new database pgx Logger

func (*PGXLogger) Log

func (l *PGXLogger) Log(_ context.Context, level pgx.LogLevel, msg string, _ map[string]interface{})

type Pool

type Pool interface {
	Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
	Exec(ctx context.Context, sql string, args ...interface{}) (pgconn.CommandTag, error)
	Begin(ctx context.Context) (pgx.Tx, error)
}

Pool for executing db commands against.

type Query

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

Query is an instance of the repository query for Postgres.

func NewQuery

func NewQuery(store *Store) *Query

NewQuery creates a new query for the Postgres database.

func (*Query) After

func (q *Query) After(key string, value interface{}) datastore.Query

func (*Query) And

func (q *Query) And(collection string, args ...interface{}) datastore.Query

func (*Query) Execute

func (q *Query) Execute(ctx context.Context) (datastore.Cursor, error)

func (*Query) Filter

func (q *Query) Filter(filter datastore.Filter) datastore.Query

func (*Query) First

func (q *Query) First(first int) datastore.Query

func (*Query) From

func (q *Query) From(collection string) datastore.Query

func (*Query) Order

func (q *Query) Order(by string) datastore.Query

func (*Query) Return

func (q *Query) Return(key string, args ...interface{}) datastore.Query

func (*Query) Secondary

func (q *Query) Secondary() datastore.Query

func (*Query) Statement

func (q *Query) Statement() (string, []interface{}, error)

type Remove

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

Remove is an instance of the repository remove command for Postgres.

func NewRemove

func NewRemove(store *Store) *Remove

NewRemove creates a remove command for the Postgres database.

func (*Remove) After

func (r *Remove) After(key string, value interface{}) datastore.Remove

func (*Remove) Execute

func (r *Remove) Execute(ctx context.Context) (int, error)

func (*Remove) Filter

func (r *Remove) Filter(filter datastore.Filter) datastore.Remove

func (*Remove) First

func (r *Remove) First(first int) datastore.Remove

func (*Remove) From

func (r *Remove) From(collection string) datastore.Remove

func (*Remove) Order

func (r *Remove) Order(by string) datastore.Remove

func (*Remove) Statement

func (r *Remove) Statement() (string, []interface{}, error)

type Store

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

Store is a client for interacting with Postgres.

func New

func New(primary string) *Store

New creates a new Postgres database client.

func (*Store) Add

func (s *Store) Add() datastore.Add

Add creates an add command for the database.

func (*Store) Connect

func (s *Store) Connect() error

func (*Store) Filter

func (s *Store) Filter() datastore.Filter

func (*Store) MaxConnLifetime

func (s *Store) MaxConnLifetime(timeout time.Duration) *Store

MaxConnLifetime sets the max lifetime for a connection.

func (*Store) MaxConns

func (s *Store) MaxConns(conns int) *Store

MaxConns sets the max number of open connections.

func (*Store) Migrations

func (s *Store) Migrations(fs fs.FS, directory string) *Store

Migrations sets the database migration configuration

func (*Store) Query

func (s *Store) Query() datastore.Query

Query creates a query for the database.

func (*Store) Remove

func (s *Store) Remove() datastore.Remove

Remove creates a remove command for the database.

func (*Store) Secondary

func (s *Store) Secondary(dsn string) *Store

func (*Store) Transaction

func (s *Store) Transaction(ctx context.Context) (datastore.Transaction, error)

Transaction creates a database transaction for Postgres.

func (*Store) Update

func (s *Store) Update() datastore.Update

Update creates an update command for the database.

type Update

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

Update is an instance of the update repository command using Postgres.

func NewUpdate

func NewUpdate(store *Store) *Update

NewUpdate creates a new update command for the Postgres database.

func (*Update) Execute

func (a *Update) Execute(ctx context.Context) (int, error)

func (*Update) Filter

func (a *Update) Filter(filter datastore.Filter) datastore.Update

func (*Update) In

func (a *Update) In(collection string) datastore.Update

func (*Update) Item

func (a *Update) Item(snapshot map[string]interface{}) datastore.Update

func (*Update) Statement

func (a *Update) Statement() (string, []interface{}, error)

Directories

Path Synopsis
Package integration provides resources for doing integration testing.
Package integration provides resources for doing integration testing.

Jump to

Keyboard shortcuts

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