postgres

package
v0.0.0-...-1db7b98 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package postgres provides an API to an Postgres3 database that conforms to domain outbound interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a Postgres client.

func New

func New(url URL) (*Client, error)

New returns a Client instance connected to the server at `url`, running any migrations that have not yet been applied.

func (*Client) Close

func (c *Client) Close() error

Close closes the database connection.

func (*Client) CreateUser

func (c *Client) CreateUser(ctx context.Context, req *user.RegistrationRequest) (*user.User, error)

CreateUser creates a new user record from the given user.RegistrationRequest and returns the created user.User.

Returns user.ValidationError if database constraints are violated.

func (*Client) GetUserByEmail

func (c *Client) GetUserByEmail(ctx context.Context, email user.EmailAddress) (*user.User, error)

GetUserByEmail returns the user.User with the given email, or user.NotFoundError if no user exists with that email.

func (*Client) GetUserByID

func (c *Client) GetUserByID(ctx context.Context, id uuid.UUID) (*user.User, error)

GetUserByID returns the user.User with the given ID, or user.NotFoundError if no such user exists.

func (*Client) UpdateUser

func (c *Client) UpdateUser(ctx context.Context, req *user.UpdateRequest) (*user.User, error)

UpdateUser updates the user record specified by `req` and returns the updated user.User.

Returns user.ValidationError if database constraints are violated.

type URL

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

URL is a Postgres connection URL.

func NewURL

func NewURL(cfg config.Config) URL

func (URL) Expose

func (u URL) Expose() string

Expose returns a connection string with the password exposed.

func (URL) GoString

func (u URL) GoString() string

GoString returns a Go-syntax representation of the URL, with the password redacted.

func (URL) String

func (u URL) String() string

String returns a connection string with the password redacted.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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