postgres

package
v0.0.0-...-c5756db Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2019 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Categories

type Categories struct {
	AgeRange       []string `db:"age_range"`
	Ethnicity      []string `db:"ethnicity"`
	Outcome        []string `db:"outcome"`
	OutcomeLinked  []string `db:"outcome_linked_to_object"`
	ObjectOfSearch []string `db:"object_of_search"`
	Legislation    []string `db:"legislation"`
}
type Search struct {
	ID        string    `json:"id,omitempty" db:"id,omitempty"`
	Force     string    `json:"force,omitempty" db:"force,omitempty"`
	MonthYear string    `json:"month_year,omitempty" db:"month_year,omitempty"`
	Time      time.Time `json:"time,omitempty" db:"time,omitempty"`
	AgeRange  string    `json:"age_range,omitempty" db:"age_range,omitempty"`
	Ethnicity string    `json:"ethnicity,omitempty" db:"ethnicity,omitempty"`
	Outcome   struct {
		SearchHappened bool   `json:"search_happened,omitempty" db:"search_happened,omitempty"`
		Desc           string `json:"desc,omitempty" db:"outcome,omitempty"`
	} `json:"outcome,omitempty"`
	Gender                string `json:"gender,omitempty" db:"gender,omitempty"`
	OutcomeLinkedToObject bool   `json:"outcome_linked_to_object,omitempty" db:"outcome_linked_to_object,omitempty"`
	ObjectOfSearch        string `json:"object_of_search,omitempty" db:"object_of_search,omitempty"`
	Legislation           string `json:"legislation,omitempty" db:"legislation"`
}

Search defines the Search form of a stop and search record

type Stat

type Stat struct {
	Name  string `db:"name"`
	Count int    `db:"count"`
}

Stat describes statistical information returned form the database.

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

Storage holds a postgres connection.

func New

func New(username, password, dbname, host string) (*Storage, error)

New returns a PostgreSQL back Storage.

func (*Storage) Close

func (s *Storage) Close()

Close closes the db connection pool

func (*Storage) CreateTables

func (s *Storage) CreateTables()

CreateTables will drop any existing tables and create new. Panics on fail.

func (*Storage) GetCategories

func (s *Storage) GetCategories() (*stats.Categories, error)

GetCategories fetches DISTINCT rows for each category

func (*Storage) GetColumnCount

func (s *Storage) GetColumnCount(column, query string, values []interface{}) ([]stats.Stat, error)

GetColumnCount returns a slice of stats representing the result of SELECT column, COUNT(column) ... WHERE ... GROUP BY column

func (*Storage) GetCount

func (s *Storage) GetCount(query string, values []interface{}) (int, error)

GetCount returns an int representing the result of `SELECT COUNT(*) WHERE`

func (*Storage) StoreSearch

func (s *Storage) StoreSearch(search ukpolice.Search) error

StoreSearch is responsible for storing search records into the database

Jump to

Keyboard shortcuts

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