userstore

package
v1.0.1-0...-61c25a1 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PostgresStore

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

PostgresStore is a type that contains the db for userstore

func NewPostgresStore

func NewPostgresStore() (*PostgresStore, error)

NewPostgresStore creates the db connection and checks if it is live

func (*PostgresStore) CreateAccount

func (s *PostgresStore) CreateAccount(acc *types.Account) error

Creates user account entry

func (*PostgresStore) DeleteAccount

func (s *PostgresStore) DeleteAccount(id int) error

Hard deletes user account from account table

func (*PostgresStore) GetAccountByID

func (s *PostgresStore) GetAccountByID(id int) (*types.Account, error)

Gets a single user account by the user's id

func (*PostgresStore) GetAccountByNumber

func (s *PostgresStore) GetAccountByNumber(number int) (*types.Account, error)

Gets a single user account by the account number

func (*PostgresStore) GetAccounts

func (s *PostgresStore) GetAccounts() ([]*types.Account, error)

Gets all accounts

func (*PostgresStore) GetMetric

func (s *PostgresStore) GetMetric(id int) (*types.QueryMetrics, error)

Gets a single metric from the metrics table based on the metric id

func (*PostgresStore) GetMetricsAll

func (s *PostgresStore) GetMetricsAll() ([]*types.QueryMetrics, error)

Gets all metrics from the metrics table

func (*PostgresStore) GetMetricsByDate

func (s *PostgresStore) GetMetricsByDate(dates types.DateTimeQuery) ([]*types.QueryMetrics, error)

Gets metrics from the metrics table based on a time.Time range

func (*PostgresStore) Init

func (s *PostgresStore) Init() error

Init initializes the user account table

type UserStorage

type UserStorage interface {
	//accounts
	CreateAccount(*types.Account) error
	DeleteAccount(int) error
	GetAccounts() ([]*types.Account, error)
	GetAccountByID(int) (*types.Account, error)
	GetAccountByNumber(int) (*types.Account, error)
	//metrics queries
	GetMetric(int) (*types.QueryMetrics, error)
	GetMetricsAll() ([]*types.QueryMetrics, error)
	GetMetricsByDate(types.DateTimeQuery) ([]*types.QueryMetrics, error)
}

UserStorage acts as in interface on all functions necessary for an API user

Jump to

Keyboard shortcuts

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