database

package
v0.0.0-...-0ba08cb Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package database implements postgres connection and queries.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUniqueEmailConstraint provides error message for already registered email address.
	ErrUniqueEmailConstraint = errors.New("email already registered")
	// ErrBadParams could not parse params to filter
	ErrBadParams = errors.New("bad parameters")
)

Functions

func DBConn

func DBConn() (*pg.DB, error)

DBConn returns a postgres connection pool.

Types

type AccountFilter

type AccountFilter struct {
	Pager  *urlvalues.Pager
	Filter *urlvalues.Filter
	Order  []string
}

AccountFilter provides pagination and filtering options on accounts.

func NewAccountFilter

func NewAccountFilter(params interface{}) (*AccountFilter, error)

NewAccountFilter returns an AccountFilter with options parsed from request url values.

func (*AccountFilter) Apply

func (f *AccountFilter) Apply(q *orm.Query) (*orm.Query, error)

Apply applies an AccountFilter on an orm.Query.

type AccountStore

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

AccountStore implements database operations for account management by user.

func NewAccountStore

func NewAccountStore(db *pg.DB) *AccountStore

NewAccountStore returns an AccountStore.

func (*AccountStore) Delete

func (s *AccountStore) Delete(a *pwdless.Account) error

Delete an account.

func (*AccountStore) DeleteToken

func (s *AccountStore) DeleteToken(t *jwt.Token) error

DeleteToken deletes a jwt refresh token.

func (*AccountStore) Get

func (s *AccountStore) Get(id int) (*pwdless.Account, error)

Get an account by ID.

func (*AccountStore) Update

func (s *AccountStore) Update(a *pwdless.Account) error

Update an account.

func (*AccountStore) UpdateToken

func (s *AccountStore) UpdateToken(t *jwt.Token) error

UpdateToken updates a jwt refresh token.

type AdmAccountStore

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

AdmAccountStore implements database operations for account management by admin.

func NewAdmAccountStore

func NewAdmAccountStore(db *pg.DB) *AdmAccountStore

NewAdmAccountStore returns an AccountStore.

func (*AdmAccountStore) Create

func (s *AdmAccountStore) Create(a *pwdless.Account) error

Create creates a new account.

func (*AdmAccountStore) Delete

func (s *AdmAccountStore) Delete(a *pwdless.Account) error

Delete account.

func (*AdmAccountStore) Get

func (s *AdmAccountStore) Get(id int) (*pwdless.Account, error)

Get account by ID.

func (*AdmAccountStore) List

List applies a filter and returns paginated array of matching results and total count.

func (*AdmAccountStore) Update

func (s *AdmAccountStore) Update(a *pwdless.Account) error

Update account.

type AuthStore

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

AuthStore implements database operations for account pwdlessentication.

func NewAuthStore

func NewAuthStore(db *pg.DB) *AuthStore

NewAuthStore return an AuthStore.

func (*AuthStore) CreateOrUpdateToken

func (s *AuthStore) CreateOrUpdateToken(t *jwt.Token) error

CreateOrUpdateToken creates or updates an existing refresh token.

func (*AuthStore) DeleteToken

func (s *AuthStore) DeleteToken(t *jwt.Token) error

DeleteToken deletes a refresh token.

func (*AuthStore) GetAccount

func (s *AuthStore) GetAccount(id int) (*pwdless.Account, error)

GetAccount returns an account by ID.

func (*AuthStore) GetAccountByEmail

func (s *AuthStore) GetAccountByEmail(e string) (*pwdless.Account, error)

GetAccountByEmail returns an account by email.

func (*AuthStore) GetToken

func (s *AuthStore) GetToken(t string) (*jwt.Token, error)

GetToken returns refresh token by token identifier.

func (*AuthStore) PurgeExpiredToken

func (s *AuthStore) PurgeExpiredToken() error

PurgeExpiredToken deletes expired refresh token.

func (*AuthStore) UpdateAccount

func (s *AuthStore) UpdateAccount(a *pwdless.Account) error

UpdateAccount upates account data related to pwdlessentication.

type ProfileStore

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

ProfileStore implements database operations for profile management.

func NewProfileStore

func NewProfileStore(db *pg.DB) *ProfileStore

NewProfileStore returns a ProfileStore implementation.

func (*ProfileStore) Get

func (s *ProfileStore) Get(accountID int) (*models.Profile, error)

Get gets an profile by account ID.

func (*ProfileStore) Update

func (s *ProfileStore) Update(p *models.Profile) error

Update updates profile.

Directories

Path Synopsis
Package migrate implements postgres migrations.
Package migrate implements postgres migrations.

Jump to

Keyboard shortcuts

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