Documentation ¶
Index ¶
- func MigrateDown(db *sql.DB, steps int, logger kitlog.Logger) error
- func MigrateDownAll(db *sql.DB, logger kitlog.Logger) error
- func MigrateUp(db *sql.DB, logger kitlog.Logger) error
- func NewMigration(dirName, migrationName string, logger kitlog.Logger) error
- func Open(connStr string) (*sqlx.DB, error)
- type Cursor
- type DB
- type Event
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MigrateDown ¶
MigrateDown attempts to run down migrations against Postgres. It takes as parameters an sql.DB instance, the number of steps to run, and a logger instance. Migrations are loaded from a bindata generated module that is compiled into the binary.
func MigrateDownAll ¶
MigrateDownAll attempts to run all down migrations against Postgres. It takes as parameters an sql.DB instance, and a logger instance. Migrations are loaded from a bindata generated module that is compiled into the binary.
func MigrateUp ¶
MigrateUp attempts to run all up migrations against Postgres. Migrations are loaded from a bindata generated module that is compiled into the binary. It takes as parameters an sql.DB instance, and a logger instance.
func NewMigration ¶
NewMigration creates a new pair of files into which an SQL migration should be written. All this is doing is ensuring files created are correctly named.
Types ¶
type Cursor ¶ added in v0.0.9
Cursor is an internal type used for serializing or parsing page cursors.
type DB ¶ added in v0.0.9
DB is a struct that wraps an sqlx.DB instance that exposes some methods to read and write data.
func NewDB ¶ added in v0.0.9
NewDB is a constructor that returns a new DB instance for the given configuration. We pass in a connection string for the database, and in addition we can pass in a verbose flag which causes the binary to output more verbose log information.
func (*DB) DeleteData ¶ added in v0.0.9
DeleteData takes as input a timestamp, and after it is executed will have deleted all events in the database from before the submitted time interval for any policy. This function also takes a `execute` parameter. If set to true the delete operation is performed and committed, but if set to false it is executed without committing the transaction. This allows a caller to see how many events would be deleted.
func (*DB) ReadData ¶ added in v0.0.9
func (d *DB) ReadData(publicKey string, pageSize uint64, startTime, endTime time.Time, pageCursor string) ([]*Event, error)
ReadData returns a list of Event types for the given query parameters.
func (*DB) Start ¶ added in v0.0.9
Start connects to the database, and runs any pending up migrations.
func (*DB) Stop ¶ added in v0.0.9
Stop terminates the DB connection, closing the pool of connections.