pgsql

package
v0.0.0-...-555e775 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(cfg *config.Database) (*pg.DB, error)

New creates new database connection to a postgres database Function panics if it can't connect to database

Types

type AccountDB

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

AccountDB represents the client for user table

func NewAccountDB

func NewAccountDB(c *pg.DB, l *zap.Logger) *AccountDB

NewAccountDB returns a new AccountDB instance

func (*AccountDB) ChangePassword

func (a *AccountDB) ChangePassword(c context.Context, usr *model.User) error

ChangePassword changes user's password

func (*AccountDB) Create

func (a *AccountDB) Create(c context.Context, usr *model.User) error

Create creates a new user on database

type UserDB

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

UserDB represents the client for user table

func NewUserDB

func NewUserDB(c *pg.DB, l *zap.Logger) *UserDB

NewUserDB returns a new UserDB instance

func (*UserDB) Delete

func (u *UserDB) Delete(c context.Context, user *model.User) error

Delete sets deleted_at for a user

func (*UserDB) FindByToken

func (u *UserDB) FindByToken(c context.Context, token string) (*model.User, error)

FindByToken queries for single user by token

func (*UserDB) FindByUsername

func (u *UserDB) FindByUsername(c context.Context, uname string) (*model.User, error)

FindByUsername queries for single user by username

func (*UserDB) List

func (u *UserDB) List(c context.Context, qp *model.ListQuery, p *model.Pagination) ([]model.User, error)

List returns list of all users retreivable for the current user, depending on role

func (*UserDB) Update

func (u *UserDB) Update(c context.Context, user *model.User) (*model.User, error)

Update updates user's contact info

func (*UserDB) UpdateLogin

func (u *UserDB) UpdateLogin(c context.Context, user *model.User) error

UpdateLogin updates last login and refresh token for user

func (*UserDB) View

func (u *UserDB) View(c context.Context, id int) (*model.User, error)

View returns single user by ID

Jump to

Keyboard shortcuts

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