Documentation
¶
Overview ¶
Package table give a logical in-memory buffer row a database table.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UnmarshalStruct ¶ added in v1.2.8
UnmarshalStruct unmarshals a table.Buffer into a slice of type T, matching fields by name or db tag. Field matching is case-sensitive. Extra columns are ignored. NULL values in non-pointer fields are set to zero values. If a field has a db tag with a "json" attribute (e.g., `db:"name,json"`), it is unmarshaled as a JSON array of objects.
func UnmarshalStructTag ¶ added in v1.2.9
UnmarshalStructTag unmarshals a table.Buffer into a slice of type T, matching fields by name or db tag. Field matching is case-sensitive. Extra columns are ignored. NULL values in non-pointer fields are set to zero values. TagName defaults to "db", but may be set. If a field has a db tag with a "json" attribute (e.g., `db:"name,json"`), it is unmarshaled as a JSON array of objects.
Types ¶
type Buffer ¶
type Buffer struct {
// Name of the table in the buffer. May be manually set for further encoding.
Name string
Row []Row // Row data.
// Truncated may be manually set to true if the returned row set has been truncated.
Truncated bool
// Result set, which should include current buffer if not nil.
Set []*Buffer
// contains filtered or unexported fields
}
Buffer represents a table buffer that holds one or more query.
func FillCommand ¶
func FillCommand(ctx context.Context, q rdb.Queryer, cmd *rdb.Command, params ...rdb.Param) (*Buffer, error)
FillCommand runs a query, fills the result, and closes the query result.
func (*Buffer) AddBufferRow ¶
AddBufferRow adds a new row to the buffer manually.
func (*Buffer) ColumnIndex ¶
ColumnIndex returns the index of the named column. If the name is not present it returns -1.
type JsonRowArray ¶
type JsonRowArray struct {
*Buffer
FlushAt int
// Additional properties to add to the output.
Meta map[string]interface{}
ResultNameName string // Default field name is "Name".
ColumnHeadersName string // Default field name is "Column".
DataRowsName string // Default field name is "Data".
}
Serialize the table buffer as an object with a column name array and an an array of rows. Each row is an array of values. Supports many result sets by chaining them together.
func (*JsonRowArray) MarshalJSON ¶
func (coder *JsonRowArray) MarshalJSON() ([]byte, error)
type JsonRowObject ¶
Serialize table buffer as an array of JSON objects. When multiple results are returned, turns into an array of arrays.
func (*JsonRowObject) MarshalJSON ¶
func (coder *JsonRowObject) MarshalJSON() ([]byte, error)
type Row ¶
Row represents a single buffer row of a table.
func (Row) Get ¶
Get returns the column name as a value, nil if null. Panics if name is not a valid column.