table

package
v0.0.0-...-e44b46f Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2019 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCode_names = map[ErrCode]string{
	E_FILTER_FIELD_UNSUPP:    "filter: field not supported for filtering",
	E_FILTER_OPERATOR_UNSUPP: "filter: operator not supported for filtering",
	E_FILTER_OPERATOR_FIELD:  "filter: operator not supported on field",
	E_ORDERBY_FIELD:          "order_by: ordering not supported on field",
	E_ORDERBY_ORDER_FIELD:    "order_by: [asc|desc] not supported on field",
	E_ORDERBY_ORDER:          "order_by: [asc|desc] generally unsupported",
}
View Source
var ErrDuplicateKey = fmt.Errorf("Duplicate Key error")
View Source
var ErrUnsupportedResult = fmt.Errorf("not supported result")

Functions

This section is empty.

Types

type ColumnFilter

type ColumnFilter struct {
	Index         int
	Operator      string
	Value, Escape interface{}
}

func (*ColumnFilter) Err

func (c *ColumnFilter) Err(code ErrCode, cols []string) (se ScanError)

func (ColumnFilter) String

func (c ColumnFilter) String() string

type ColumnOrder

type ColumnOrder struct {
	Index int
	Desc  bool
}

func (*ColumnOrder) Err

func (c *ColumnOrder) Err(code ErrCode, cols []string) (se ScanError)

func (*ColumnOrder) Operator

func (c *ColumnOrder) Operator() string

func (ColumnOrder) String

func (c ColumnOrder) String() string

type ErrCode

type ErrCode int
const (
	E_FILTER_FIELD_UNSUPP ErrCode = iota
	E_FILTER_OPERATOR_UNSUPP
	E_FILTER_OPERATOR_FIELD
	E_ORDERBY_FIELD
	E_ORDERBY_ORDER_FIELD
	E_ORDERBY_ORDER
)

type InsertableTable

type InsertableTable interface {
	Table

	TablePrepareInsert(ti *TableInsert) (TableInsertStmt, error)
}

type ModifyResult

type ModifyResult [2]*int64

func (*ModifyResult) LastInsertId

func (r *ModifyResult) LastInsertId() (int64, error)

func (*ModifyResult) RowsAffected

func (r *ModifyResult) RowsAffected() (int64, error)

type ScanError

type ScanError struct {
	ErrCode
	Operator    string
	FieldIndex  int
	FieldString string
}

func (ScanError) Error

func (c ScanError) Error() string

type Table

type Table interface {
	Columns() []string

	// 'cols' must be specified, an the same array must be used in
	// any .Next() call onto the returned TableIterator object.
	// Otherwise the behavoir is undefined.
	//
	// If the *TableScan object is not acceptible, return an error,
	// preferribly a ScanError{}
	TableScan(cols []int, meta *TableScan) (TableIterator, error)
}

This interface represents a Scannable Table.

var tab table.Table
cols := []int{0,1,2,3}
vals := make([]interface{},4)

iter,_ := tab.TableScan(cols,new(table.TableScan))
defer iter.Close()
for {
	err := iter.Next(cols,vals)
	if err != nil {
		break
	}
}

type TableInsert

type TableInsert struct {
	AllCols bool
	Cols    []int

	Values [][]interface{}
	Op     TableOp

	OndupCols []int
	OndupVals []interface{}
}

type TableInsertStmt

type TableInsertStmt interface {
	Close() error
	Abort() error

	TableInsert(ti *TableInsert) (*ModifyResult, error)
}

type TableIterator

type TableIterator interface {
	Close() error
	// Scan the next row. Return nil on success, io.EOF on end-of-table
	// and any other error if there is a true error.
	Next(cols []int, vals []interface{}) error
}

type TableOp

type TableOp int
const (
	// Insert Job
	T_Insert TableOp = iota
	T_InsertIgnore
	T_Replace

	// Update/Delete Job
	T_Update
	T_Delete
)

type TableScan

type TableScan struct {
	Filter []ColumnFilter
	Order  []ColumnOrder
}

type TableUpdate

type TableUpdate struct {
	Op   TableOp
	Scan *TableScan

	UpdCols []int
	UpdVals []interface{}
}

type TableUpdateStmt

type TableUpdateStmt interface {
	Close() error
	Abort() error

	TableUpdate(tu *TableUpdate) (*ModifyResult, error)
}

type UpdateableTable

type UpdateableTable interface {
	Table

	TablePrepareUpdate(tu *TableUpdate) (TableUpdateStmt, error)
}

Directories

Path Synopsis
impl
Utilities for implementors.
Utilities for implementors.

Jump to

Keyboard shortcuts

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