table

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2019 License: Zlib Imports: 5 Imported by: 2

Documentation

Overview

package table creates table buffers for results from database/sql.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewScaler

func NewScaler(ctx context.Context, db *sql.DB, sql string, params ...interface{}) (interface{}, error)

NewScaler returns the first field in the first row.

Types

type Buffer

type Buffer struct {
	Columns []string
	Rows    []Row
	// contains filtered or unexported fields
}

Buffer is a result within memory.

func NewBuffer

func NewBuffer(ctx context.Context, db *sql.DB, sql string, params ...interface{}) (table *Buffer, err error)

NewBuffer returns a new single table buffer.

func (*Buffer) RowValue

func (t *Buffer) RowValue(rowIndex int, columnName string) interface{}

RowValue of the field from the row index and named column.

type IndexError

type IndexError struct {
	// contains filtered or unexported fields
}

Error returned when attempting to access a row or column which does not exist.

func (*IndexError) Error

func (tie *IndexError) Error() string

type Row

type Row struct {
	Field []interface{}
	// contains filtered or unexported fields
}

Row hold field level data.

func (Row) MarshalJSON

func (r Row) MarshalJSON() ([]byte, error)

func (Row) UnmarshalJSON

func (r Row) UnmarshalJSON(bb []byte) error

func (Row) Value

func (r Row) Value(columnName string) interface{}

Value of the field from the named column.

type Set

type Set []*Buffer

Set stores a list of Buffers.

func FillSet

func FillSet(ctx context.Context, rows *sql.Rows) (Set, error)

FillSet will take a sql query result and fill the buffer with the entire result set.

func NewSet

func NewSet(ctx context.Context, db *sql.DB, sql string, params ...interface{}) (Set, error)

NewSet returns a set of table buffers from the given query.

Jump to

Keyboard shortcuts

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