Documentation ¶
Index ¶
- func CastType(iface interface{}) string
- type Batch
- type Result
- type Row
- func (r *Row) Get(field string) *Value
- func (r *Row) GetDefault(field string, defaultValue interface{}) *Value
- func (r *Row) GetFloat(field string) float64
- func (r *Row) GetFloats(blacklist []string) *map[string]float64
- func (r *Row) GetInt(field string) int
- func (r *Row) GetString(field string) string
- func (r *Row) GetStruct(structPointer interface{})
- func (r *Row) GetTime(field string) time.Time
- type Timescale
- func (ts *Timescale) BulkInsert(table string, data []map[string]interface{})
- func (ts *Timescale) Close() error
- func (ts *Timescale) Connect() (err error)
- func (ts *Timescale) ExecAndCommit(query string, args ...interface{}) error
- func (ts *Timescale) FindByID(table string, id int) *Result
- func (ts *Timescale) FuncString(input string) func() string
- func (ts *Timescale) Get(strc interface{}, query string) error
- func (ts *Timescale) Insert(table string, data map[string]interface{})
- func (ts *Timescale) InsertStruct(table string, data interface{})
- func (ts *Timescale) ProcessBatch(b *Batch, copyCmd, splitChar string) (int, error)
- func (ts *Timescale) Query(query string, data map[string]interface{}) *Result
- func (ts *Timescale) QueryByRow(query string, data map[string]interface{}, fn func(row *Row))
- func (ts *Timescale) QuerySelect(strc interface{}, query string, data map[string]interface{}) error
- func (ts *Timescale) Select(dest interface{}, query string) error
- func (ts *Timescale) Update(table string, data map[string]interface{}, where string)
- func (ts *Timescale) UpdateByID(table string, data map[string]interface{}, id int)
- type Value
- func (v *Value) AsBool() bool
- func (v *Value) AsByte() []byte
- func (v *Value) AsFloat() float64
- func (v *Value) AsFloats() []float64
- func (v *Value) AsInt() int
- func (v *Value) AsInt64() int64
- func (v *Value) AsInterface() interface{}
- func (v *Value) AsJSON(target interface{})
- func (v *Value) AsString() string
- func (v *Value) AsTime() time.Time
- func (v *Value) BinaryToInt() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Row ¶
type Row struct {
Data map[string]interface{}
}
Row contains Data of one Timescale row as a map where map keys are column names.
func (*Row) GetDefault ¶
Get data from given column as Value. Returns defaultvalue if no data found.
func (*Row) GetFloat ¶ added in v0.23.0
Get data from given column as float64. Returns NaN if no data found.
func (*Row) GetFloats ¶ added in v0.23.0
Get all convertible data as float64 and return as a map. Blacklist of columns can be given to exclude certain columns.
func (*Row) GetInt ¶ added in v0.23.0
Get data from given column as int. Returns -1 if no data found.
func (*Row) GetStruct ¶ added in v0.23.0
func (r *Row) GetStruct(structPointer interface{})
Fills the given struct with data from Timescale row. The struct to be filled is given as a pointer. Function will fill all the struct's fields it finds and leaves the rest of the fields untouched. Thus default values can be set to struct prior to filling it. NOTE: Struct field name must match the timescale column name, except that struct field always needs capital letter
type Timescale ¶
type Timescale struct { DB *sqlx.DB Error string // Error string // contains filtered or unexported fields }
Timescale parameters.
func (*Timescale) BulkInsert ¶
Insert multiple records
func (*Timescale) Connect ¶
Connect to Timescale. SSL is set as disabled and hostname is used as the application name. In case of not being able to connect, Error string is updated.
func (*Timescale) ExecAndCommit ¶
ExecAndCommit ExecAndCommit
func (*Timescale) FuncString ¶ added in v0.24.0
FuncString funcstring
func (*Timescale) InsertStruct ¶
Insert single struct
func (*Timescale) ProcessBatch ¶ added in v0.23.0
Batch processing for fast raw data writing to Timescale. Returns the number of records written and possible error.
func (*Timescale) QueryByRow ¶ added in v0.23.0
QueryByRow goes through the data row by row with MapScan and executes given function for each row.
func (*Timescale) QuerySelect ¶ added in v0.24.0
QuerySelect select
type Value ¶
type Value struct {
Raw interface{}
}
Value struct contains the Raw data of unknown type
func (*Value) AsInterface ¶
func (v *Value) AsInterface() interface{}
Returns raw value as interface.
func (*Value) BinaryToInt ¶
Returns raw binary value as int. Returns 0 if no value.