postgres

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2021 License: GPL-3.0 Imports: 19 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 IsIntegrityConstraintViolation

func IsIntegrityConstraintViolation(err error) bool

IsIntegrityConstraintViolation checks if the error is an integrity constraint violation.

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) Item

func (a *Add) Item(value 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) 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 Cond added in v0.0.26

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

Cond is an instance of filter conditions for pg queries

func (Cond) And added in v0.0.26

func (f Cond) And(another Cond) Cond

And conjunction

func (Cond) BeginsWith added in v0.0.26

func (f Cond) BeginsWith(key string, value string) Cond

BeginsWith is the LIKE 'foo%' operation

func (Cond) Contains added in v0.0.26

func (f Cond) Contains(key string, value interface{}) Cond

Contains is the LIKE '%foo%' operation for strings or IN operator for arrays

func (Cond) EndsWith added in v0.0.26

func (f Cond) EndsWith(key string, value string) Cond

EndsWith is the LIKE '%foo' operation

func (Cond) Eq added in v0.0.26

func (f Cond) Eq(key string, value interface{}) Cond

Eq is the = operator

func (Cond) Gt added in v0.0.26

func (f Cond) Gt(key string, value interface{}) Cond

Gt is the > operator

func (Cond) Lt added in v0.0.26

func (f Cond) Lt(key string, value interface{}) Cond

Lt is the < operator

func (Cond) NotContains added in v0.0.26

func (f Cond) NotContains(key string, value interface{}) Cond

NotContains is the NOT LIKE '%foo%' operation for strings or NOT IN operator for arrays

func (Cond) NotEq added in v0.0.26

func (f Cond) NotEq(key string, value interface{}) Cond

NotEq is the <> operator

func (Cond) Or added in v0.0.26

func (f Cond) Or(another Cond) Cond

Or conjunction

func (Cond) Raw added in v0.0.26

func (f Cond) Raw(sql string, args ...interface{}) Cond

Raw constructs a raw pg Cond

func (Cond) ToSql added in v0.0.26

func (f Cond) ToSql() (string, []interface{}, error)

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, data map[string]interface{})

type Pool

type Pool interface {
	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 *time.Time) client.Query

func (*Query) Complement added in v0.0.22

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

func (*Query) Field added in v0.0.21

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

func (*Query) Fields added in v0.0.21

func (q *Query) Fields(fields ...interface{}) client.Query

func (*Query) Filter

func (q *Query) Filter(filter interface{}) 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) Secondary

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

func (*Query) Statement

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

func (*Query) Transform added in v0.0.21

func (q *Query) Transform(transform func(string) string) client.Query

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 *time.Time) client.Remove

func (*Remove) Filter

func (r *Remove) Filter(filter interface{}) 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) Filter

func (u *Update) Filter(filter interface{}) client.Update

func (*Update) In

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

func (*Update) Item

func (u *Update) Item(value map[string]interface{}) client.Update

func (*Update) Statement

func (u *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