Documentation ¶
Index ¶
- type DB
- type PGCovidStore
- func (store *PGCovidStore) Add(entries []models.CountryEntry) error
- func (store *PGCovidStore) CountEntriesByTime(from, to time.Time) ([]TimestampCount, error)
- func (store *PGCovidStore) GetAllCountryNames() (names []string, err error)
- func (store *PGCovidStore) GetAllForCountryName(countryName string) ([]models.CountryEntry, error)
- func (store *PGCovidStore) GetAllForRange(from, to time.Time) ([]models.CountryEntry, error)
- func (store *PGCovidStore) GetLatestForCountries(endTime time.Time) (map[string]models.CountryEntry, error)
- func (store *PGCovidStore) GetTotalsPerDay() ([]models.CountryEntry, error)
- func (store *PGCovidStore) Rows() (int, error)
- type PGPopulationStore
- type TimestampCount
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct { Collector prometheus.Collector Handle *sqlx.DB // contains filtered or unexported fields }
DB hold the handle to a database. Provides a Prometheus DBStatsCollector to monitor DB connections
type PGCovidStore ¶ added in v1.2.0
type PGCovidStore struct {
DB *DB
}
PGCovidStore implements CovidStore for Postgres databases
func NewCovidStore ¶ added in v1.2.0
func NewCovidStore(db *DB) *PGCovidStore
NewCovidStore creates a new PGCovidStore and initializes the database, if necessary
func (*PGCovidStore) Add ¶ added in v1.2.0
func (store *PGCovidStore) Add(entries []models.CountryEntry) error
Add inserts new entries in the database
func (*PGCovidStore) CountEntriesByTime ¶ added in v1.2.0
func (store *PGCovidStore) CountEntriesByTime(from, to time.Time) ([]TimestampCount, error)
CountEntriesByTime counts updates per timestamp
func (*PGCovidStore) GetAllCountryNames ¶ added in v1.2.0
func (store *PGCovidStore) GetAllCountryNames() (names []string, err error)
GetAllCountryNames gets all unique country names from the database
func (*PGCovidStore) GetAllForCountryName ¶ added in v1.2.0
func (store *PGCovidStore) GetAllForCountryName(countryName string) ([]models.CountryEntry, error)
GetAllForCountryName returns all entries in the database, sorted by timestamp
func (*PGCovidStore) GetAllForRange ¶ added in v1.2.0
func (store *PGCovidStore) GetAllForRange(from, to time.Time) ([]models.CountryEntry, error)
GetAllForRange returns all entries in the database, sorted by timestamp
func (*PGCovidStore) GetLatestForCountries ¶ added in v1.2.0
func (store *PGCovidStore) GetLatestForCountries(endTime time.Time) (map[string]models.CountryEntry, error)
GetLatestForCountries gets the last entries for each country up the specified endTime. If endTime is time.Time{}, it will get the latest entries up to the current time.
func (*PGCovidStore) GetTotalsPerDay ¶ added in v1.2.0
func (store *PGCovidStore) GetTotalsPerDay() ([]models.CountryEntry, error)
GetTotalsPerDay returns the total new cases per day across all countries
func (*PGCovidStore) Rows ¶ added in v1.3.1
func (store *PGCovidStore) Rows() (int, error)
Rows returns the number of rows in the store
type PGPopulationStore ¶ added in v1.2.0
type PGPopulationStore struct {
DB *DB
}
PGPopulationStore implements PopulationStore for Postgres databases
func NewPopulationStore ¶ added in v1.2.0
func NewPopulationStore(db *DB) *PGPopulationStore
NewPopulationStore creates a new PostgresDB object