db

package
v0.0.0-...-df2f5af Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

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) Close

func (p *PostgreSQL) Close()

Close closes the PostgreSQL connection

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.

Jump to

Keyboard shortcuts

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