postgres

package
v0.41.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PostgresAPI

type PostgresAPI interface {
	// Exec executes a query without returning any rows.
	Exec(ctx context.Context, sql string, args ...any) (pgconn.CommandTag, error)
	// QueryRow executes a query that is expected to return at most one row.
	QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
	// Query executes a query that returns rows.
	Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
}

PostgresAPI defines the API surface from pgx that we use. This is used to allow for easier testing.

Keep these definitions in sync with pgxpool.Pool and pgx.Conn.

type PostgresClient

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

PostgresClient is a storage client that uses Postgres as the backend.

func NewPostgresClient

func NewPostgresClient(api PostgresAPI) *PostgresClient

NewPostgresClient creates a new PostgresClient.

func (*PostgresClient) Delete

func (p *PostgresClient) Delete(ctx context.Context, id string, options ...store.DeleteOptions) error

Delete implements store.StorageClient.

func (*PostgresClient) Get

func (p *PostgresClient) Get(ctx context.Context, id string, options ...store.GetOptions) (*store.Object, error)

Get implements store.StorageClient.

func (*PostgresClient) Query

func (p *PostgresClient) Query(ctx context.Context, query store.Query, options ...store.QueryOptions) (*store.ObjectQueryResult, error)

Query implements store.StorageClient.

func (*PostgresClient) Save

func (p *PostgresClient) Save(ctx context.Context, obj *store.Object, options ...store.SaveOptions) error

Save implements store.StorageClient.

Jump to

Keyboard shortcuts

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