Documentation
¶
Index ¶
- type ExtraIndex
- type MongoDB
- func (m *MongoDB) AllCompanies(ctx context.Context, cursor *string, limit uint32) ([]string, *string, error)
- func (m *MongoDB) Close()
- func (m *MongoDB) Create() error
- func (m *MongoDB) CreateCompanies(ctx context.Context, batch [][]string) error
- func (m *MongoDB) CreateExtraIndexes(idxs []string) error
- func (m *MongoDB) Drop() error
- func (m *MongoDB) GetCompany(ctx context.Context, id string) (string, error)
- func (m *MongoDB) MetaRead(k string) (string, error)
- func (m *MongoDB) MetaSave(k, v string) error
- func (m *MongoDB) PostLoad() error
- func (m *MongoDB) PreLoad() error
- func (m *MongoDB) Search(ctx context.Context, q *Query) (string, error)
- type PostgreSQL
- func (p *PostgreSQL) AllCompanies(ctx context.Context, cursor *string, limit uint32) ([]string, *string, error)
- func (p *PostgreSQL) Close()
- func (p *PostgreSQL) CompanyTableFullName() string
- func (p *PostgreSQL) Create() error
- func (p *PostgreSQL) CreateCompanies(ctx context.Context, batch [][]string) error
- func (p *PostgreSQL) CreateExtraIndexes(idxs []string) error
- func (p *PostgreSQL) Drop() error
- func (p *PostgreSQL) GetCompany(ctx context.Context, 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
- func (p *PostgreSQL) Search(ctx context.Context, q *Query) (string, error)
- type Query
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExtraIndex ¶
func (*ExtraIndex) NestedPath ¶
func (e *ExtraIndex) NestedPath() string
type MongoDB ¶
type MongoDB struct {
// contains filtered or unexported fields
}
func NewMongoDB ¶
NewMongoDB initializes a new MongoDB connection wrapped in a structure.
func (*MongoDB) AllCompanies ¶
func (m *MongoDB) AllCompanies(ctx context.Context, cursor *string, limit uint32) ([]string, *string, error)
AllCompanies returns a paginated list of CNPJ numbers from the database.
func (*MongoDB) CreateCompanies ¶
CreateCompanies writes a batch of company data to MongoDB
func (*MongoDB) CreateExtraIndexes ¶
func (*MongoDB) GetCompany ¶
func (*MongoDB) MetaSave ¶
MetaSave inserts if the key doesn't exist, or updates the value if it does.
func (*MongoDB) PostLoad ¶
PostLoad runs after loading data into the database. Removes duplicates and creates indexes.
type PostgreSQL ¶
type PostgreSQL struct {
CompanyTableName string
MetaTableName string
CursorFieldName string
IDFieldName string
JSONFieldName string
KeyFieldName string
ValueFieldName string
ExtraIndexes []ExtraIndex
// contains filtered or unexported fields
}
PostgreSQL database interface.
func NewPostgreSQL ¶
func NewPostgreSQL(uri, schema string) (PostgreSQL, error)
NewPostgreSQL creates a new PostgreSQL connection and ping it to make sure it works.
func (*PostgreSQL) AllCompanies ¶
func (p *PostgreSQL) AllCompanies(ctx context.Context, cursor *string, limit uint32) ([]string, *string, error)
AllCompanies returns a paginated list of CNPJ numbers from the database.
func (*PostgreSQL) CompanyTableFullName ¶
func (p *PostgreSQL) CompanyTableFullName() string
CompanyTableFullName is the name of the schame and table in dot-notation.
func (*PostgreSQL) Create ¶
func (p *PostgreSQL) Create() error
Create creates the required database table.
func (*PostgreSQL) CreateCompanies ¶
func (p *PostgreSQL) CreateCompanies(ctx context.Context, 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) CreateExtraIndexes ¶
func (p *PostgreSQL) CreateExtraIndexes(idxs []string) error
CreateExtraIndexes responsible for creating additional indexes in the database
func (*PostgreSQL) Drop ¶
func (p *PostgreSQL) Drop() error
Drop drops the database table created by `Create`.
func (*PostgreSQL) GetCompany ¶
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.