Back to

Package pgsql

Latest Go to latest

The latest major version is .

Published: Nov 1, 2019 | License: MIT | Module:


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

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

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier