postgres

package
v0.0.3 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() client.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) client.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(client *Client) *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{}) client.Add

func (*Add) Query

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

func (*Add) Statement

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

func (*Add) To

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

type Client added in v0.0.2

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

Client is a client for interacting with Postgres.

func New

func New(primary string) *Client

New creates a new Postgres database client.

func (*Client) Add added in v0.0.2

func (c *Client) Add() client.Add

Add creates an add command for the database.

func (*Client) Connect added in v0.0.2

func (c *Client) Connect() error

func (*Client) Filter added in v0.0.2

func (c *Client) Filter() client.Filter

func (*Client) MaxConnLifetime added in v0.0.2

func (c *Client) MaxConnLifetime(timeout time.Duration) *Client

MaxConnLifetime sets the max lifetime for a connection.

func (*Client) MaxConns added in v0.0.2

func (c *Client) MaxConns(conns int) *Client

MaxConns sets the max number of open connections.

func (*Client) Migrations added in v0.0.2

func (c *Client) Migrations(fs fs.FS, directory string) *Client

Migrations sets the database migration configuration

func (*Client) Query added in v0.0.2

func (c *Client) Query() client.Query

Query creates a query for the database.

func (*Client) Remove added in v0.0.2

func (c *Client) Remove() client.Remove

Remove creates a remove command for the database.

func (*Client) Secondary added in v0.0.2

func (c *Client) Secondary(dsn string) *Client

func (*Client) Transaction added in v0.0.2

func (c *Client) Transaction(ctx context.Context) (client.Transaction, error)

Transaction creates a database transaction for Postgres.

func (*Client) Update added in v0.0.2

func (c *Client) Update() client.Update

Update creates an update command for the database.

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(client *Client) *Query

NewQuery creates a new query for the Postgres database.

func (*Query) After

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

func (*Query) And

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

func (*Query) Execute

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

func (*Query) Filter

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

func (*Query) First

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

func (*Query) From

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

func (*Query) Order

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

func (*Query) Return

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

func (*Query) Secondary

func (q *Query) Secondary() client.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(client *Client) *Remove

NewRemove creates a remove command for the Postgres database.

func (*Remove) After

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

func (*Remove) Execute

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

func (*Remove) Filter

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

func (*Remove) First

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

func (*Remove) From

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

func (*Remove) Order

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

func (*Remove) Statement

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

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(client *Client) *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 client.Filter) client.Update

func (*Update) In

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

func (*Update) Item

func (a *Update) Item(snapshot map[string]interface{}) client.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