db

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDB

func NewDB(driver string, connection string) *database

Types

type ColumnType

type ColumnType string
const (
	ColumnTypeUnknown ColumnType = "UNKNOWN"
	ColumnTypeBoolean ColumnType = "BOOL"
	ColumnTypeInteger ColumnType = "INTEGER"
	ColumnTypeFloat   ColumnType = "FLOAT"
	ColumnTypeString  ColumnType = "STRING"
	ColumnTypeTime    ColumnType = "TIME"
)

type ColumnTypes

type ColumnTypes map[string]ColumnType

func (ColumnTypes) GetColumnNames

func (columnTypes ColumnTypes) GetColumnNames() []string

type ColumnValue

type ColumnValue struct {
	Type ColumnType
	// contains filtered or unexported fields
}

func NewColumnValue

func NewColumnValue(val any, typ ColumnType) *ColumnValue

func UnknownTypeColumnValue

func UnknownTypeColumnValue(val any) *ColumnValue

func (ColumnValue) AsBool

func (v ColumnValue) AsBool() (NullBool, error)

func (ColumnValue) AsBytes

func (v ColumnValue) AsBytes() (NullBytes, error)

func (ColumnValue) AsFloat

func (v ColumnValue) AsFloat() (NullFloat, error)

func (ColumnValue) AsInteger

func (v ColumnValue) AsInteger() (NullInteger, error)

func (ColumnValue) AsString

func (v ColumnValue) AsString() (NullString, error)

func (ColumnValue) AsTime

func (v ColumnValue) AsTime() (NullTime, error)

func (ColumnValue) WithType

func (v ColumnValue) WithType(typ ColumnType) *ColumnValue

type DB

type DB interface {
	RunTransaction(ctx context.Context, handler func(ctx context.Context, tx Tx) error) error
	Open() error
	Close() error
}

type NullBool

type NullBool sql.NullBool

type NullBytes

type NullBytes struct {
	Bytes []byte
	Valid bool
}

type NullFloat

type NullFloat sql.NullFloat64

type NullInteger

type NullInteger sql.NullInt64

type NullString

type NullString sql.NullString

type NullTime

type NullTime sql.NullTime

type Row

type Row map[string]*ColumnValue

type Schema

type Schema struct {
	PrimaryKeys  []string
	ColumnTypes  ColumnTypes
	Dependencies []string
}

func (Schema) GetColumnNames

func (schema Schema) GetColumnNames() []string

type Table

type Table struct {
	Name   string
	Schema Schema
	Rows   []Row
}

type Tables

type Tables map[string]Table

type Tx

type Tx interface {
	Write(ctx context.Context, stmt string, params []any) (err error)
	Read(ctx context.Context, stmt string, params []any) (rows []Row, err error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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