postgres

package
v0.0.0-...-87faeab Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	//Host e.g. localhost:5432
	Host string
	//Password is the database user's password
	Password string
	//User is the database username
	User string
	//Name is the database name
	Name string
	//MaxIdleConns is the maximum number of conns in the idle conn pool
	MaxIdleConns int
	//MaxOpenConns is the maximum number of open conns to the database.
	MaxOpenConns int
	//DisableTLS enable TLS on connections to the database.
	DisableTLS bool
}

type PostgresqlContainer

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

func NewPostgresqlContainer

func NewPostgresqlContainer(pool *dockertest.Pool) *PostgresqlContainer

func (*PostgresqlContainer) Create

func (container *PostgresqlContainer) Create(t *testing.T)

type Store

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

Store is a postgresql implementation of our store interface

func NewStore

func NewStore(cfg *Config) (*Store, error)

NewStore creates and returns an initialized postgresql store for use as our state backend.

func NewTestDatabase

func NewTestDatabase(t *testing.T) (*Store, func())

func (Store) GetURLByID

func (u Store) GetURLByID(ctx context.Context, id uuid.UUID) (store.URL, error)

GetURLByID retrieves the short url by its given id.

func (Store) GetURLByLongStr

func (u Store) GetURLByLongStr(ctx context.Context, longURL string) (store.URL, error)

GetURLByLongStr retrieves the short url of the given long url.

func (Store) GetURLByParam

func (u Store) GetURLByParam(ctx context.Context, param string) (store.URL, error)

GetURLByParam retrieves the short url by its given param.

func (Store) GetUserByEmail

func (s Store) GetUserByEmail(ctx context.Context, email string) (store.User, error)

GetUserByEmail retrieves an existing user with the given email.

func (Store) GetUserByID

func (s Store) GetUserByID(ctx context.Context, id uuid.UUID) (store.User, error)

GetUserByID finds a user by id

func (Store) GetUserByVerificationToken

func (s Store) GetUserByVerificationToken(ctx context.Context, token uuid.UUID) (store.User, error)

GetUserByVerificationToken retrieves user whose verification token matches the given token string.

func (Store) NewURL

func (u Store) NewURL(ctx context.Context, userID uuid.UUID, originalURL, shortenedURLParam string) (store.URL, error)

NewURL creates a new url record.

func (Store) NewUser

func (s Store) NewUser(ctx context.Context, email, password string) (store.User, error)

NewUser creates a new user record.

func (Store) SetUserAPIKey

func (s Store) SetUserAPIKey(ctx context.Context, id, key uuid.UUID) error

SetUserAPIKey sets the api key for the given user id.

func (Store) SetUserVerified

func (s Store) SetUserVerified(ctx context.Context, id uuid.UUID) error

SetUserVerified updates the verified value for the user with the given user id.

Jump to

Keyboard shortcuts

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