Documentation ¶
Overview ¶
Package sql implements a SQL-backed, SQL-queryable, bitemporal database. This implements the key-value oriented interface of bitempura.DB and provides SQL querying. WARNING: WIP. this implementation is experimental.
Index ¶
- func ScanToMaps(rows *sql.Rows) ([]map[string]interface{}, error)
- func ScanToVersionedKVs(pkColumnName string, rows *sql.Rows) ([]*bt.VersionedKV, error)
- func StateTableName(tableName string) string
- type DB
- type ExecerQueryer
- type TableDB
- func (db *TableDB) Delete(key string, opts ...bt.WriteOpt) error
- func (db *TableDB) Get(key string, opts ...bt.ReadOpt) (*bt.VersionedKV, error)
- func (db *TableDB) History(key string) ([]*bt.VersionedKV, error)
- func (db *TableDB) List(opts ...bt.ReadOpt) ([]*bt.VersionedKV, error)
- func (db *TableDB) Select(b squirrel.SelectBuilder, opts ...bt.ReadOpt) (*sql.Rows, error)
- func (db *TableDB) Set(key string, value bt.Value, opts ...bt.WriteOpt) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ScanToMaps ¶
ScanToMaps generically scans SQL rows into a slice of maps with columns as map keys. Caller should defer rows.Close() but does not need to call rows.Err()
func ScanToVersionedKVs ¶
ScanToVersionedKVs generically scans SQL rows into a slice of VersionedKV's. Caller should defer rows.Close() but does not need to call rows.Err()
func StateTableName ¶ added in v0.2.4
StateTableName returns the default bitemporal state table name for a given table.
Types ¶
type DB ¶
type DB interface { bt.DB // Select executes a SQL query (as of optional valid and transaction times). Select(query squirrel.SelectBuilder, opts ...bt.ReadOpt) (*sql.Rows, error) }
DB is a SQL-backed, SQL-queryable, bitemporal database. WARNING: WIP. this implementation is experimental.
func NewTableDB ¶
func NewTableDB(eq ExecerQueryer, table string, pkColumnName string, updatedAtColName, deletedAtColName *string) (DB, error)
NewTableDB constructs a SQL-backed, SQL-queryable, bitemporal database connected to a specific underlying SQL table. WARNING: WIP. this implementation is experimental.
type ExecerQueryer ¶
type ExecerQueryer interface { Exec(query string, args ...interface{}) (sql.Result, error) Query(query string, args ...interface{}) (*sql.Rows, error) QueryRow(query string, args ...interface{}) *sql.Row }
ExecerQueryer can Exec or Query. Both sql.DB and sql.Tx satisfy this interface.
type TableDB ¶
type TableDB struct {
// contains filtered or unexported fields
}
TableDB is a SQL-backed, SQL-queryable, bitemporal database that is connected to a specific underlying SQL table.
func (*TableDB) Delete ¶
Delete removes value (with optional start and end valid time). WARNING: unimplemented
func (*TableDB) History ¶
func (db *TableDB) History(key string) ([]*bt.VersionedKV, error)
History returns versions by descending end transaction time, descending end valid time