Documentation ¶
Index ¶
- type PostgreSQL
- func (p *PostgreSQL) Close()
- func (p *PostgreSQL) CompanyTableFullName() string
- func (p *PostgreSQL) CreateCompanies(batch [][]string) error
- func (p *PostgreSQL) CreateTable() error
- func (p *PostgreSQL) DropTable() error
- func (p *PostgreSQL) GetCompany(id string) (string, error)
- func (p *PostgreSQL) MetaRead(k string) (string, error)
- func (p *PostgreSQL) MetaSave(k, v string) error
- func (p *PostgreSQL) MetaTableFullName() string
- func (p *PostgreSQL) PostLoad() error
- func (p *PostgreSQL) PreLoad() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PostgreSQL ¶
type PostgreSQL struct { CompanyTableName string MetaTableName string IDFieldName string JSONFieldName string KeyFieldName string ValueFieldName string PartnersJSONFieldName string // contains filtered or unexported fields }
PostgreSQL database interface.
func NewPostgreSQL ¶
func NewPostgreSQL(uri, schema string, nr *newrelic.Application) (PostgreSQL, error)
NewPostgreSQL creates a new PostgreSQL connection and ping it to make sure it works.
func (*PostgreSQL) CompanyTableFullName ¶
func (p *PostgreSQL) CompanyTableFullName() string
CompanyTableFullName is the name of the schame and table in dot-notation.
func (*PostgreSQL) CreateCompanies ¶
func (p *PostgreSQL) CreateCompanies(batch [][]string) error
CreateCompanies performs a copy to create a batch of companies in the database. It expects an array and each item should be another array with only two items: the ID and the JSON field values.
func (*PostgreSQL) CreateTable ¶
func (p *PostgreSQL) CreateTable() error
CreateTable creates the required database table.
func (*PostgreSQL) DropTable ¶
func (p *PostgreSQL) DropTable() error
DropTable drops the database table created by `CreateTable`.
func (*PostgreSQL) GetCompany ¶
func (p *PostgreSQL) GetCompany(id string) (string, error)
GetCompany returns the JSON of a company based on a CNPJ number.
func (*PostgreSQL) MetaRead ¶
func (p *PostgreSQL) MetaRead(k string) (string, error)
MetaRead reads a key/value pair from the metadata table.
func (*PostgreSQL) MetaSave ¶
func (p *PostgreSQL) MetaSave(k, v string) error
MetaSave saves a key/value pair in the metadata table.
func (*PostgreSQL) MetaTableFullName ¶
func (p *PostgreSQL) MetaTableFullName() string
MetaTableFullName is the name of the schame and table in dot-notation.
func (*PostgreSQL) PostLoad ¶
func (p *PostgreSQL) PostLoad() error
PostLoad runs after loading data into the database. Currently it re-enables autovacuum on PostgreSQL.
func (*PostgreSQL) PreLoad ¶
func (p *PostgreSQL) PreLoad() error
PreLoad runs before starting to load data into the database. Currently it disables autovacuum on PostgreSQL.