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: 13 Imported by: 0

Documentation

Overview

Package db contains transaction related CRUD functionality.

Index

Constants

View Source
const (
	DocType = "txn"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type NewTransaction

type NewTransaction struct {
	ID *string `json:"_id"`
	models.Transaction
	DocType                string   `json:"doc_type"`
	AssociatedAccounts     []string `json:"associated_accounts"`
	AssociatedApplications []uint64 `json:"associated_applications"`
	AssociatedAssets       []uint64 `json:"associated_assets"`
}

type Store

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

func NewStore

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

NewStore constructs a transaction store for api access.

func (Store) AddTransaction

func (s Store) AddTransaction(ctx context.Context, transaction models.Transaction, blockInfo types.Block) (string, string, error)

AddTransaction adds a transaction to CouchDB. It receives the models.Transaction object and transform it into a Transaction document object and then insert it into the global CouchDB table.

func (Store) AddTransactions

func (s Store) AddTransactions(ctx context.Context, transactions []models.Transaction, blockInfo types.Block) (bool, error)

AddTransactions bulk-adds transactions to CouchDB. It receives the []models.Transaction object and transform them into Transaction document objects and then insert them into the global CouchDB table.

func (Store) GetEarliestAcctTransaction

func (s Store) GetEarliestAcctTransaction(ctx context.Context, acctID string) (Transaction, error)

GetEarliestAcctTransaction retrieves the earliest Transaction for an account that can be found in the database.

func (Store) GetEarliestAppTransaction

func (s Store) GetEarliestAppTransaction(ctx context.Context, appID string) (Transaction, error)

GetEarliestAppTransaction retrieves the earliest Transaction for an account that can be found in the database.

func (Store) GetEarliestAssetTransaction

func (s Store) GetEarliestAssetTransaction(ctx context.Context, assetID string) (Transaction, error)

GetEarliestAssetTransaction retrieves the earliest Transaction for an account that can be found in the database.

func (Store) GetEarliestTransaction

func (s Store) GetEarliestTransaction(ctx context.Context) (Transaction, error)

GetEarliestTransaction retrieves the latest Transaction that can be found in the database.

func (Store) GetLatestAcctTransaction

func (s Store) GetLatestAcctTransaction(ctx context.Context, acctID string) (Transaction, error)

GetLatestAcctTransaction retrieves the latest Transaction for an account that can be found in the database.

func (Store) GetLatestAppTransaction

func (s Store) GetLatestAppTransaction(ctx context.Context, appID string) (Transaction, error)

GetLatestAppTransaction retrieves the latest Transaction for an account that can be found in the database.

func (Store) GetLatestAssetTransaction

func (s Store) GetLatestAssetTransaction(ctx context.Context, assetID string) (Transaction, error)

GetLatestAssetTransaction retrieves the latest Transaction for an account that can be found in the database.

func (Store) GetLatestTransaction

func (s Store) GetLatestTransaction(ctx context.Context) (Transaction, error)

GetLatestTransaction retrieves the latest Transaction that can be found in the database.

func (Store) GetTransaction

func (s Store) GetTransaction(ctx context.Context, transactionID string) (models.Transaction, error)

GetTransaction retrieves a transaction record from CouchDB based upon the transaction ID given.

func (Store) GetTransactionCountBtnKeys

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

GetTransactionCountBtnKeys gets the count between a transaction and another. The transactions are arranged in chronological order in the view. 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) GetTransactionCountByAcct

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

func (Store) GetTransactionsByAcct

func (s Store) GetTransactionsByAcct(ctx context.Context, acctID string, order string) ([]Transaction, error)

func (Store) GetTransactionsByAcctPagination

func (s Store) GetTransactionsByAcctPagination(ctx context.Context, acctID, order string, pageNo, limit int64) ([]Transaction, int64, int64, error)

func (Store) GetTransactionsByApp

func (s Store) GetTransactionsByApp(ctx context.Context, appID string, order string) ([]Transaction, error)

func (Store) GetTransactionsByAsset

func (s Store) GetTransactionsByAsset(ctx context.Context, assetID string, order string) ([]Transaction, error)

func (Store) GetTransactionsPagination

func (s Store) GetTransactionsPagination(ctx context.Context, startTransactionId, order string, pageNo, limit int64) ([]Transaction, int64, int64, error)

type Transaction

type Transaction struct {
	NewTransaction
	ID  string `json:"_id,omitempty"`
	Rev string `json:"_rev,omitempty"`
}

Jump to

Keyboard shortcuts

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