database

package
v0.0.0-...-521f081 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2017 License: MIT Imports: 7 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")
)

Functions

func DBConn

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

DBConn returns a postgres connection pool.

Types

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 *auth.Account) error

Delete an account.

func (*AccountStore) DeleteToken

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

DeleteToken deletes a jwt refresh token.

func (*AccountStore) Get

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

Get an account by ID.

func (*AccountStore) Update

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

Update an account.

func (*AccountStore) UpdateToken

func (s *AccountStore) UpdateToken(t *auth.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 *auth.Account) error

Create creates a new account.

func (*AdmAccountStore) Delete

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

Delete account.

func (*AdmAccountStore) Get

func (s *AdmAccountStore) Get(id int) (*auth.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 *auth.Account) error

Update account.

type AuthStore

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

AuthStore implements database operations for account authentication.

func NewAuthStore

func NewAuthStore(db *pg.DB) *AuthStore

NewAuthStore return an AuthStore.

func (*AuthStore) DeleteRefreshToken

func (s *AuthStore) DeleteRefreshToken(t *auth.Token) error

DeleteRefreshToken deletes a refresh token.

func (*AuthStore) GetByEmail

func (s *AuthStore) GetByEmail(e string) (*auth.Account, error)

GetByEmail returns an account by email.

func (*AuthStore) GetByID

func (s *AuthStore) GetByID(id int) (*auth.Account, error)

GetByID returns an account by ID.

func (*AuthStore) GetByRefreshToken

func (s *AuthStore) GetByRefreshToken(t string) (*auth.Account, *auth.Token, error)

GetByRefreshToken returns an account and refresh token by token identifier.

func (*AuthStore) PurgeExpiredToken

func (s *AuthStore) PurgeExpiredToken() error

PurgeExpiredToken deletes expired refresh token.

func (*AuthStore) SaveRefreshToken

func (s *AuthStore) SaveRefreshToken(t *auth.Token) error

SaveRefreshToken creates or updates a refresh token.

func (*AuthStore) UpdateAccount

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

UpdateAccount upates account data related to authentication.

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