Documentation ¶
Overview ¶
Package db contains transaction related CRUD functionality.
Index ¶
- Constants
- type NewTransaction
- type Store
- func (s Store) AddTransaction(ctx context.Context, transaction models.Transaction, blockInfo types.Block) (string, string, error)
- func (s Store) AddTransactions(ctx context.Context, transactions []models.Transaction, blockInfo types.Block) (bool, error)
- func (s Store) GetEarliestAcctTransaction(ctx context.Context, acctID string) (Transaction, error)
- func (s Store) GetEarliestAppTransaction(ctx context.Context, appID string) (Transaction, error)
- func (s Store) GetEarliestAssetTransaction(ctx context.Context, assetID string) (Transaction, error)
- func (s Store) GetEarliestTransaction(ctx context.Context) (Transaction, error)
- func (s Store) GetLatestAcctTransaction(ctx context.Context, acctID string) (Transaction, error)
- func (s Store) GetLatestAppTransaction(ctx context.Context, appID string) (Transaction, error)
- func (s Store) GetLatestAssetTransaction(ctx context.Context, assetID string) (Transaction, error)
- func (s Store) GetLatestTransaction(ctx context.Context) (Transaction, error)
- func (s Store) GetTransaction(ctx context.Context, transactionID string) (models.Transaction, error)
- func (s Store) GetTransactionCountBtnKeys(ctx context.Context, startKey, endKey string) (int64, error)
- func (s Store) GetTransactionCountByAcct(ctx context.Context, acctID, startKey, endKey string) (int64, error)
- func (s Store) GetTransactionsByAcct(ctx context.Context, acctID string, order string) ([]Transaction, error)
- func (s Store) GetTransactionsByAcctPagination(ctx context.Context, acctID, order string, pageNo, limit int64) ([]Transaction, int64, int64, error)
- func (s Store) GetTransactionsByApp(ctx context.Context, appID string, order string) ([]Transaction, error)
- func (s Store) GetTransactionsByAsset(ctx context.Context, assetID string, order string) ([]Transaction, error)
- func (s Store) GetTransactionsPagination(ctx context.Context, startTransactionId, order string, pageNo, limit int64) ([]Transaction, int64, int64, error)
- type Transaction
Constants ¶
const (
DocType = "txn"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NewTransaction ¶
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 ¶
GetEarliestAcctTransaction retrieves the earliest Transaction for an account that can be found in the database.
func (Store) GetEarliestAppTransaction ¶
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 ¶
GetLatestAcctTransaction retrieves the latest Transaction for an account that can be found in the database.
func (Store) GetLatestAppTransaction ¶
GetLatestAppTransaction retrieves the latest Transaction for an account that can be found in the database.
func (Store) GetLatestAssetTransaction ¶
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 (Store) GetTransactionsByAcct ¶
func (Store) GetTransactionsByAcctPagination ¶
func (Store) GetTransactionsByApp ¶
func (Store) GetTransactionsByAsset ¶
type Transaction ¶
type Transaction struct { NewTransaction ID string `json:"_id,omitempty"` Rev string `json:"_rev,omitempty"` }