postgres

package
v0.0.0-...-bc46c97 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package postgres provides an API to a postgres database that aligns with the domain outbount 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 Posgres client

func New

func New(ctx context.Context, url URL) (*Client, error)

create a new PostgresClient

func (*Client) Close

func (c *Client) Close() error

close the database connection pool

func (*Client) CreateSession

func (c *Client) CreateSession(ctx context.Context, session *ss.Sessions) error

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

func (c *Client) DeleteSession(ctx context.Context, id uuid.UUID) error

func (*Client) DeleteUser

func (c *Client) DeleteUser(ctx context.Context, id uuid.UUID) error

func (*Client) GetSession

func (c *Client) GetSession(ctx context.Context, id uuid.UUID) (*ss.Sessions, error)

func (*Client) GetSessionByUserID

func (c *Client) GetSessionByUserID(ctx context.Context, userID uuid.UUID) (*ss.Sessions, error)

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.NotFoundErr if no user exists with 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.NotFoundErr if no such user is found

func (*Client) ListSessions

func (c *Client) ListSessions(ctx context.Context, userID uuid.UUID, pageSize int32, pageNumber int32) ([]*ss.Sessions, int32, error)

func (*Client) RevokeSession

func (c *Client) RevokeSession(ctx context.Context, id uuid.UUID) error

func (*Client) UpdateUser

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

UpdateUser updates the user record and returns the updated user.User Returns user.ValidationError if database constriants 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
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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