sql

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: MIT Imports: 6 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ScanToMaps

func ScanToMaps(rows *sql.Rows) ([]map[string]interface{}, error)

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

func ScanToVersionedKVs(pkColumnName string, rows *sql.Rows) ([]*bt.VersionedKV, error)

ScanToVersionedKVs generically scans SQL rows into a slice of VersionedKV's. Caller should defer rows.Close() but does not need to call rows.Err()

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

func (db *TableDB) Delete(key string, opts ...bt.WriteOpt) error

Delete removes value (with optional start and end valid time). WARNING: unimplemented

func (*TableDB) Get

func (db *TableDB) Get(key string, opts ...bt.ReadOpt) (*bt.VersionedKV, error)

Get data by key (as of optional valid and transaction times). 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 WARNING: unimplemented

func (*TableDB) List

func (db *TableDB) List(opts ...bt.ReadOpt) ([]*bt.VersionedKV, error)

List all data (as of optional valid and transaction times). WARNING: unimplemented

func (*TableDB) Select

func (db *TableDB) Select(b squirrel.SelectBuilder, opts ...bt.ReadOpt) (*sql.Rows, error)

Select executes a SQL query (as of optional valid and transaction times).

func (*TableDB) Set

func (db *TableDB) Set(key string, value bt.Value, opts ...bt.WriteOpt) error

Set stores value (with optional start and end valid time). WARNING: unimplemented

Jump to

Keyboard shortcuts

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