Documentation ¶
Overview ¶
Package db contains asset related CRUD functionality.
Index ¶
- Constants
- type Asset
- type NewAsset
- type Store
- func (s Store) AddAsset(ctx context.Context, asset models.Asset) (string, string, error)
- func (s Store) AddAssets(ctx context.Context, assets []models.Asset) (bool, error)
- func (s Store) GetAsset(ctx context.Context, assetID string) (models.Asset, error)
- func (s Store) GetAssetCountBtnKeys(ctx context.Context, startKey, endKey string) (int64, error)
- func (s Store) GetAssetsPagination(ctx context.Context, latestAssetID string, order string, pageNo, limit int64) ([]Asset, int64, int64, error)
- func (s Store) GetEarliestAssetID(ctx context.Context) (string, error)
- func (s Store) GetLatestAssetID(ctx context.Context) (string, error)
Constants ¶
View Source
const (
DocType = "asset"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 an asset store for api access.
func (Store) AddAsset ¶
AddAsset adds an asset to CouchDB. It receives the models.Asset object and transform it into an Asset document object and then insert it into the global CouchDB table.
func (Store) AddAssets ¶
AddAssets bulk-adds assets to CouchDB. It receives the []models.Asset object and transform them into Asset document objects and then insert them into the global CouchDB table.
func (Store) GetAsset ¶
GetAsset retrieves a asset record from CouchDB based upon the asset ID given.
func (Store) GetAssetCountBtnKeys ¶
GetAssetCountBtnKeys 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) GetAssetsPagination ¶
func (Store) GetEarliestAssetID ¶
Click to show internal directories.
Click to hide internal directories.