Documentation ¶
Overview ¶
Package database implements postgres connection and queries.
Index ¶
- Variables
- func DBConn() (*pg.DB, error)
- type AccountFilter
- type AccountStore
- type AdmAccountStore
- func (s *AdmAccountStore) Create(a *pwdless.Account) error
- func (s *AdmAccountStore) Delete(a *pwdless.Account) error
- func (s *AdmAccountStore) Get(id int) (*pwdless.Account, error)
- func (s *AdmAccountStore) List(f *AccountFilter) ([]pwdless.Account, int, error)
- func (s *AdmAccountStore) Update(a *pwdless.Account) error
- type AuthStore
- func (s *AuthStore) CreateOrUpdateToken(t *jwt.Token) error
- func (s *AuthStore) DeleteToken(t *jwt.Token) error
- func (s *AuthStore) GetAccount(id int) (*pwdless.Account, error)
- func (s *AuthStore) GetAccountByEmail(e string) (*pwdless.Account, error)
- func (s *AuthStore) GetToken(t string) (*jwt.Token, error)
- func (s *AuthStore) PurgeExpiredToken() error
- func (s *AuthStore) UpdateAccount(a *pwdless.Account) error
- type ProfileStore
Constants ¶
This section is empty.
Variables ¶
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 ¶
Types ¶
type AccountFilter ¶
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.
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 ¶
func (s *AdmAccountStore) List(f *AccountFilter) ([]pwdless.Account, int, error)
List applies a filter and returns paginated array of matching results and total count.
type AuthStore ¶
type AuthStore struct {
// contains filtered or unexported fields
}
AuthStore implements database operations for account pwdlessentication.
func (*AuthStore) CreateOrUpdateToken ¶
CreateOrUpdateToken creates or updates an existing refresh token.
func (*AuthStore) DeleteToken ¶
DeleteToken deletes a refresh token.
func (*AuthStore) GetAccount ¶
GetAccount returns an account by ID.
func (*AuthStore) GetAccountByEmail ¶
GetAccountByEmail returns an account by email.
func (*AuthStore) PurgeExpiredToken ¶
PurgeExpiredToken deletes expired refresh token.
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.