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

Documentation

Overview

Package db contains application related CRUD functionality.

Index

Constants

View Source
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

func (Store) GetApplicationsPagination

func (s Store) GetApplicationsPagination(ctx context.Context, latestApplicationID string, order string, pageNo, limit int64) ([]Application, int64, int64, error)

func (Store) GetEarliestApplicationID

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

func (Store) GetLatestApplicationID

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

Jump to

Keyboard shortcuts

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