Documentation ¶
Overview ¶
Package db contains application related CRUD functionality.
Index ¶
- Constants
- type Application
- type NewApplication
- type Store
- func (s Store) AddApplication(ctx context.Context, application models.Application) (string, string, error)
- func (s Store) AddApplications(ctx context.Context, applications []models.Application) (bool, error)
- func (s Store) GetApplication(ctx context.Context, applicationID string) (models.Application, error)
- func (s Store) GetApplicationCountBtnKeys(ctx context.Context, startKey, endKey string) (int64, error)
- func (s Store) GetApplicationsPagination(ctx context.Context, latestApplicationID string, order string, ...) ([]Application, int64, int64, error)
- func (s Store) GetEarliestApplicationID(ctx context.Context) (string, error)
- func (s Store) GetLatestApplicationID(ctx context.Context) (string, error)
Constants ¶
const (
DocType = "app"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application struct { NewApplication ID string `json:"_id,omitempty"` Rev string `json:"_rev,omitempty"` }
type NewApplication ¶
type NewApplication struct { ID *string `json:"_id"` models.Application DocType string `json:"doc_type"` }
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 application store for api access.
func (Store) AddApplication ¶
func (s Store) AddApplication(ctx context.Context, application models.Application) (string, string, error)
AddApplication adds an application to CouchDB. It receives the models.Application object and transform it into a Application document object and then insert it into the global CouchDB table.
func (Store) AddApplications ¶
func (s Store) AddApplications(ctx context.Context, applications []models.Application) (bool, error)
AddApplications bulk-adds applications to CouchDB. It receives the []models.Application object and transform them into Application document objects and then insert them into the global CouchDB table.
func (Store) GetApplication ¶
func (s Store) GetApplication(ctx context.Context, applicationID string) (models.Application, error)
GetApplication retrieves an application record from CouchDB based upon the application ID given.
func (Store) GetApplicationCountBtnKeys ¶
func (s Store) GetApplicationCountBtnKeys(ctx context.Context, startKey, endKey string) (int64, error)
GetApplicationCountBtnKeys 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