db

package
v0.0.0-...-8401909 Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package db contains account related CRUD functionality.

Index

Constants

View Source
const (
	DocType = "acct"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	NewAccount
	ID  string `json:"_id,omitempty"`
	Rev string `json:"_rev,omitempty"`
}

type NewAccount

type NewAccount struct {
	ID *string `json:"_id"`
	models.Account
	DocType string `json:"doc_type"`
}

type Store

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

Store manages the set of API's for account access.

func NewStore

func NewStore(log *zap.SugaredLogger, couchClient *kivik.Client, dbName string) Store

NewStore constructs an account store for api access.

func (Store) AddAccount

func (s Store) AddAccount(ctx context.Context, account models.Account) (string, string, error)

AddAccount adds an account to CouchDB. It receives the models.Account object and transform it into an Account document object and then insert it into the global CouchDB table.

func (Store) AddAccounts

func (s Store) AddAccounts(ctx context.Context, accounts []models.Account) (bool, error)

AddAccounts bulk-adds accounts to CouchDB. It receives the []models.Account object and transform them into Account document objects and then insert them into the global CouchDB table.

func (Store) GetAccount

func (s Store) GetAccount(ctx context.Context, accountAddr string) (models.Account, error)

GetAccount retrieves a account record from CouchDB based upon the account ID given.

func (Store) GetAccountCountBtnKeys

func (s Store) GetAccountCountBtnKeys(ctx context.Context, startKey, endKey string) (int64, error)

GetAccountCountBtnKeys retrieves the number of keys between two keys References:

https://stackoverflow.com/questions/11284383/couchdb-count-unique-document-field
https://stackoverflow.com/questions/12944294/using-a-couchdb-view-can-i-count-groups-and-filter-by-key-range-at-the-same-tim

func (Store) GetAccountsPagination

func (s Store) GetAccountsPagination(ctx context.Context, latestAccountID string, order string, pageNo, limit int64) ([]Account, int64, int64, error)

func (Store) GetEarliestAccountID

func (s Store) GetEarliestAccountID(ctx context.Context) (string, error)

func (Store) GetLatestAccountID

func (s Store) GetLatestAccountID(ctx context.Context) (string, error)

Jump to

Keyboard shortcuts

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