table

package
v0.0.0-...-2ecc45d Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrEmptyTableName means table's name is empty
	ErrEmptyTableName = errors.New("empty table name")
	//ErrEmptyTableNamePart means there are empty table's name's part. E.g., "db..name", "db.", "db.name.""
	ErrEmptyTableNamePart = errors.New("empty table name part")
	//ErrTableNameInvalidBacktick means there is no closing/opening backtick it table's name
	ErrTableNameInvalidBacktick = errors.New("table name has invalid backtick")
	//ErrEmptyFields means fields are empty
	ErrEmptyFields = errors.New("empty  fields")
	//ErrEmptyField one of fields is empty ("field1,,field2")
	ErrEmptyField = errors.New("fields contain empty field (check commas)")
	//ErrFieldInvalidBacktick means there is no closing/opening backtick it fields
	ErrFieldInvalidBacktick = errors.New("one of the fields has invalid backtick")
)
View Source
var ErrWrongRowLen = errors.New("")

ErrWrongRowLen - when row elements count doesn't match table's fields count

Functions

This section is empty.

Types

type Signature

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

Signature is table's name and fields

func NewSignature

func NewSignature(tableName, fields string) Signature

NewSignature creates new TableSignature from name and fields

func (Signature) GetKey

func (ts Signature) GetKey() string

GetKey returns a key from table name and fields to identify table

func (Signature) Validate

func (ts Signature) Validate() error

Validate validates table signature

type Table

type Table struct {
	Signature
	// contains filtered or unexported fields
}

Table is an abstract table that has name, fields and it's data (rows)

func NewTable

func NewTable(ts Signature) *Table

NewTable creates new table by signature

func (*Table) AppendRows

func (t *Table) AppendRows(rowsJSON []byte) error

AppendRows parses rowsJSON as [][]interface{}, validates and appends to table's inner data buffer

func (*Table) Free

func (t *Table) Free()

Free frees table's resources

func (Table) GetFields

func (t Table) GetFields() string

GetFields returns table's fields

func (*Table) GetNextRow

func (t *Table) GetNextRow() []interface{}

GetNextRow iterates over table's data buffer and returns each row. When the end of data is reached returns nil and reset's inner iteration position.

func (*Table) GetRawData

func (t *Table) GetRawData() []interface{}

func (Table) GetRowsLen

func (t Table) GetRowsLen() int

GetRowsLen returns count of table's rows

func (Table) GetTableName

func (t Table) GetTableName() string

GetTableName returns table's name

func (*Table) Reset

func (t *Table) Reset()

Jump to

Keyboard shortcuts

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