postgres

package
v0.0.0-...-3975a26 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2021 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package postgres provides functionality for interaction with postgres database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store contains dependencies needed for direct communication with the postgres data store.

func NewStore

func NewStore(log zerolog.Logger, db *sqlx.DB, d time.Duration) (*Store, error)

NewStore creates a fresh instance of the store. Last parameter specifies how often should the inactive users' cleanup operation execute. 0 disables cleanup.

func (*Store) CreateUser

func (s *Store) CreateUser(ctx context.Context, usr user.User) error

CreateUser inserts the freshly created user into the underlying data store.

func (*Store) DeleteUserByID

func (s *Store) DeleteUserByID(ctx context.Context, id xid.ID) error

DeleteUserByID deletes the user from the underlying data store by their ID.

func (*Store) FetchManyUsers

func (s *Store) FetchManyUsers(ctx context.Context, qr httpflow.Query) ([]user.User, int, error)

FetchManyUsers retrieves multiple users from the underlying data store by the provided query. Int return value specifies the total page count.

func (*Store) FetchUserByEmail

func (s *Store) FetchUserByEmail(ctx context.Context, eml string) (user.User, error)

FetchUserByEmail retrieves a user from the underlying data store by their email address.

func (*Store) FetchUserByID

func (s *Store) FetchUserByID(ctx context.Context, id xid.ID) (user.User, error)

FetchUserByID retrieves a user from the underlying data store by their ID.

func (*Store) UpdateUser

func (s *Store) UpdateUser(ctx context.Context, usr user.User) error

UpdateUser updates user's data in the underlying data store.

func (*Store) UserStats

func (s *Store) UserStats(ctx context.Context) (user.Stats, error)

UserStats returns users' data statistics from the underlying data store.

Jump to

Keyboard shortcuts

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