datatable

package module
v0.0.0-...-fba9b14 Latest Latest
Warning

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

Go to latest
Published: May 18, 2020 License: MIT Imports: 7 Imported by: 2

README

datatable

DataTable for any Golang sql abstraction

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cell

type Cell struct {
	ColumnName   string
	ColumnIndex  int
	RowIndex     int
	DBColumnType string
	Value        interface{}
}

Cell - a location for the value

type Column

type Column struct {
	Name   string
	Type   reflect.Type
	DBType string
	Length int64
}

Column - a column in the data table

type DataTable

type DataTable struct {
	Name        string
	Columns     []Column
	Rows        []Row
	RowCount    int
	ColumnCount int
}

DataTable - the object

func NewDataTable

func NewDataTable(Name string) *DataTable

NewDataTable - create a new datatable

func (*DataTable) AddColumn

func (dt *DataTable) AddColumn(name string, vartype reflect.Type, length int64, DBType string)

AddColumn - add a new column to the data table

func (*DataTable) AddColumns

func (dt *DataTable) AddColumns(newcolumns []Column)

AddColumns - add a new columns to the data table

func (*DataTable) AddRow

func (dt *DataTable) AddRow(row *Row)

AddRow - add a row to the current rows

func (*DataTable) AddRows

func (dt *DataTable) AddRows(rows []Row)

AddRows - adds a range of rows to the current data table

func (*DataTable) NewRow

func (dt *DataTable) NewRow() Row

NewRow - returns a new row based on column structure

type Row

type Row struct {
	Cells       []Cell
	ColumnCount int

	ResultRows []interface{} //raw variable to as a result for calling Next() in a GetDataReader() call
	// contains filtered or unexported fields
}

Row - a row in the data table

func (*Row) Close

func (rw *Row) Close()

Close - closes sqlRow from a GetDataReader function call. Also resets the values in its cells

func (*Row) Next

func (rw *Row) Next() bool

Next - gets the next row from a GetDataReader function call

func (*Row) SetSQLRow

func (rw *Row) SetSQLRow(rows *sql.Rows)

SetSQLRow - sets a pointer to an sql.Row object to allow next row reading

func (*Row) SetValue

func (rw *Row) SetValue(StructItem interface{}, FieldIndex string)

SetValue - sets a struct item with a value from the row specified by an index

func (*Row) SetValueByOrd

func (rw *Row) SetValueByOrd(StructItem interface{}, FieldIndex int)

SetValueByOrd - sets a struct item with a value from the row specified by an index ordinal

func (*Row) Value

func (rw *Row) Value(index interface{}) interface{}

Value - get row cell values

func (*Row) ValueBool

func (rw *Row) ValueBool(index string) bool

ValueBool - return the value as boolean or a false if the value is null. This can also be used for columns that resembles a boolean value, and converting it to boolean. Column values such as `true`, 'on', 'yes', '1' or 1 and -1 are converted to true value. Anything else than these are converted to false

func (*Row) ValueBoolOrd

func (rw *Row) ValueBoolOrd(index int) bool

ValueBoolOrd - return the value as boolean or a false if the value is null by ordinal

func (*Row) ValueByName

func (rw *Row) ValueByName(index *string) interface{}

ValueByName - get values by column name index

func (*Row) ValueByOrdinal

func (rw *Row) ValueByOrdinal(index *int) interface{}

ValueByOrdinal - get values by ordinal index

func (*Row) ValueByte

func (rw *Row) ValueByte(index string) byte

ValueByte - return the value as byte or a 0 if the value is null

func (*Row) ValueByteOrd

func (rw *Row) ValueByteOrd(index int) byte

ValueByteOrd - return the value as byte or a 0 if the value is null by ordinal

func (*Row) ValueFloat32

func (rw *Row) ValueFloat32(index string) float32

ValueFloat32 - return the value as float32 or a 0 if the value is null

func (*Row) ValueFloat32Ord

func (rw *Row) ValueFloat32Ord(index int) float32

ValueFloat32Ord - return the value as float32 or a 0 if the value is null by ordinal

func (*Row) ValueFloat64

func (rw *Row) ValueFloat64(index string) float64

ValueFloat64 - return the value as float64 or a 0 if the value is null

func (*Row) ValueFloat64Ord

func (rw *Row) ValueFloat64Ord(index int) float64

ValueFloat64Ord - return the value as float64 or a 0 if the value is null by ordinal

func (*Row) ValueInt

func (rw *Row) ValueInt(index string) int

ValueInt - return the value as int or a 0 if the value is null

func (*Row) ValueInt16

func (rw *Row) ValueInt16(index string) int16

ValueInt16 - return the value as int16 or a 0 if the value is null

func (*Row) ValueInt16Ord

func (rw *Row) ValueInt16Ord(index int) int16

ValueInt16Ord - return the value as int16 or a 0 if the value is null by ordinal

func (*Row) ValueInt32

func (rw *Row) ValueInt32(index string) int32

ValueInt32 - return the value as int32 or a 0 if the value is null

func (*Row) ValueInt32Ord

func (rw *Row) ValueInt32Ord(index int) int32

ValueInt32Ord - return the value as int32 or a 0 if the value is null by ordinal

func (*Row) ValueInt64

func (rw *Row) ValueInt64(index string) int64

ValueInt64 - return the value as int64 or a 0 if the value is null

func (*Row) ValueInt64Ord

func (rw *Row) ValueInt64Ord(index int) int64

ValueInt64Ord - return the value as int64 or a 0 if the value is null by ordinal

func (*Row) ValueIntOrd

func (rw *Row) ValueIntOrd(index int) int

ValueIntOrd - return the value as int or a 0 if the value is null by ordinal

func (*Row) ValuePtrBool

func (rw *Row) ValuePtrBool(index string) *bool

ValuePtrBool - return the value as pointer to boolean or nil if the value is null This can also be used for columns that resembles a boolean value, and converting it to boolean. Column values such as `true`, 'on', 'yes', '1' or 1 and -1 are converted to true value. Anything else than these are converted to false

func (*Row) ValuePtrBoolOrd

func (rw *Row) ValuePtrBoolOrd(index int) *bool

ValuePtrBoolOrd - return the value as pointer to boolean or a nil if the value is null by ordinal

func (*Row) ValuePtrByte

func (rw *Row) ValuePtrByte(index string) *byte

ValuePtrByte - return the value as pointer to byte or a nil if the value is null

func (*Row) ValuePtrByteOrd

func (rw *Row) ValuePtrByteOrd(index int) *byte

ValuePtrByteOrd - return the value as pointer to byte or a nil if the value is null by ordinal

func (*Row) ValuePtrFloat32

func (rw *Row) ValuePtrFloat32(index string) *float32

ValuePtrFloat32 - return the value as pointer to float32 or a nil if the value is null

func (*Row) ValuePtrFloat32Ord

func (rw *Row) ValuePtrFloat32Ord(index int) *float32

ValuePtrFloat32Ord - return the value as pointer float32 or a nil if the value is null by ordinal

func (*Row) ValuePtrFloat64

func (rw *Row) ValuePtrFloat64(index string) *float64

ValuePtrFloat64 - return the value as pointer to float64 or a nil if the value is null

func (*Row) ValuePtrFloat64Ord

func (rw *Row) ValuePtrFloat64Ord(index int) *float64

ValuePtrFloat64Ord - return the value as pointer to float64 or a nil if the value is null by ordinal

func (*Row) ValuePtrInt

func (rw *Row) ValuePtrInt(index string) *int

ValuePtrInt - return the value as pointer to int or a nil if the value is null

func (*Row) ValuePtrInt16

func (rw *Row) ValuePtrInt16(index string) *int16

ValuePtrInt16 - return the value as pointer to int16 or a nil if the value is null

func (*Row) ValuePtrInt16Ord

func (rw *Row) ValuePtrInt16Ord(index int) *int16

ValuePtrInt16Ord - return the value as pointer to int16 or a nil if the value is null by ordinal

func (*Row) ValuePtrInt32

func (rw *Row) ValuePtrInt32(index string) *int32

ValuePtrInt32 - return the value as pointer to int32 or a nil if the value is null

func (*Row) ValuePtrInt32Ord

func (rw *Row) ValuePtrInt32Ord(index int) *int32

ValuePtrInt32Ord - return the value as pointer to int32 or a nil if the value is null by ordinal

func (*Row) ValuePtrInt64

func (rw *Row) ValuePtrInt64(index string) *int64

ValuePtrInt64 - return the value as pointer to int64 or a nil if the value is null

func (*Row) ValuePtrInt64Ord

func (rw *Row) ValuePtrInt64Ord(index int) *int64

ValuePtrInt64Ord - return the value as pointer to int64 or a nil if the value is null by ordinal

func (*Row) ValuePtrIntOrd

func (rw *Row) ValuePtrIntOrd(index int) *int

ValuePtrIntOrd - return the value as pointer to int or a nil if the value is null by ordinal

func (*Row) ValuePtrString

func (rw *Row) ValuePtrString(index string) *string

ValuePtrString - return the value as pointer to string or nil if the value is null

func (*Row) ValuePtrStringOrd

func (rw *Row) ValuePtrStringOrd(index int) *string

ValuePtrStringOrd - return the value as pointer to string or nil if the value is null

func (*Row) ValuePtrTime

func (rw *Row) ValuePtrTime(index string) *time.Time

ValuePtrTime - return the value as pointer to time.Time or nil if the value is null

func (*Row) ValuePtrTimeOrd

func (rw *Row) ValuePtrTimeOrd(index int) *time.Time

ValuePtrTimeOrd - return the value as pointer time.Time or a nil if the value is null by ordinal

func (*Row) ValueString

func (rw *Row) ValueString(index string) string

ValueString - return the value as string or a default empty string if the value is null

func (*Row) ValueStringOrd

func (rw *Row) ValueStringOrd(index int) string

ValueStringOrd - return the value as string or a default empty string if the value is null by ordinal

func (*Row) ValueTime

func (rw *Row) ValueTime(index string) time.Time

ValueTime - return the value as time.Time or a default empty time.Time if the value is null

func (*Row) ValueTimeOrd

func (rw *Row) ValueTimeOrd(index int) time.Time

ValueTimeOrd - return the value as time.Time or a default empty time.Time if the value is null by ordinal

Jump to

Keyboard shortcuts

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