resultset

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: Apache-2.0 Imports: 6 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column interface {
	// Name returns the column name.
	Name() string
	// DataType returns the data type.
	DataType() DataType
	// Constraint returns the column constraint.
	Constraint() Constraint
}

Column represents a column interface in a resultset.

func NewColumn

func NewColumn(opts ...ColumnOption) Column

ResultSetColumn represents a resultset column interface.

func NewColumnFrom

func NewColumnFrom(column query.Column) (Column, error)

NewColumnFrom returns a new resultset column from the specified column.

func NewColumnsFrom

func NewColumnsFrom(column query.Columns) []Column

NewColumnsFrom returns a new resultset columns from the specified column list.

type ColumnOption

type ColumnOption func(*column)

ResultSetColumnOptions represents a functional option for resultsetColumn.

func WithColumnConstraint

func WithColumnConstraint(c Constraint) ColumnOption

WithColumnConstraint returns a functional option for resultsetColumn.

func WithColumnName

func WithColumnName(name string) ColumnOption

WithColumnName returns a functional option for resultsetColumn.

func WithColumnType

func WithColumnType(t DataType) ColumnOption

WithColumnType returns a functional option for resultsetColumn.

type Constraint

type Constraint = query.Constraint

Constraint represents a column constraint.

type DataType

type DataType = query.DataType

DataType represents a data type.

type ResultSet

type ResultSet interface {
	// Schema returns the schema.
	Schema() Schema
	// Next returns the next row.
	Next() bool
	// Row returns the current row.
	Row() (Row, error)
	// RowsAffected returns the number of rows affected.
	RowsAffected() uint64
	// Close closes the resultset.
	Close() error
}

ResultSet represents a response resultset interface.

func NewResultSet

func NewResultSet(opts ...ResultSetOption) ResultSet

NewResultSet returns a new ResultSet.

type ResultSetOption

type ResultSetOption func(*resultset)

ResultSet represents a response resultset interface.

func WithResultSetRows added in v1.5.0

func WithResultSetRows(rows []Row) ResultSetOption

WithResultSetRows returns a resultset option to set the rows.

func WithResultSetRowsAffected added in v1.5.0

func WithResultSetRowsAffected(rowsAffected uint64) ResultSetOption

WithResultSetRowsAffected returns a resultset option to set the rows affected.

func WithResultSetSchema added in v1.5.0

func WithResultSetSchema(schema Schema) ResultSetOption

WithResultSetSchema returns a resultset option to set the schema.

type Row

type Row interface {
	// Object returns the row object.
	Object() map[string]any
	// Values returns the row values.
	Values() []any
	// ValueAt returns the row value at the specified index.
	ValueAt(int) (any, error)
	// ValueBy returns the row value by the specified name.
	ValueBy(string) (any, error)
	// Scan scans the values.
	Scan(...any) error
	// ScanAt scans the value at the specified index.
	ScanAt(int, any) error
	// ScanBy scans the value by the specified name.
	ScanBy(string, any) error
}

Row represents a row interface.

func NewRow

func NewRow(opts ...RowOption) Row

NewRow returns a new resultsetRow.

type RowOption added in v1.4.2

type RowOption func(*row)

RowOption represents a functional option for Row.

func WithRowObject

func WithRowObject(object map[string]any) RowOption

WithRowObject returns a functional option for row object.

func WithRowSchema

func WithRowSchema(schema Schema) RowOption

WithRowSchema returns a functional option for row schema.

func WithRowValues

func WithRowValues(values []any) RowOption

WithRowValues returns a functional option for row values.

type Schema

type Schema interface {
	// DatabaseName returns the database name.
	DatabaseName() string
	// TableName returns the table name.
	TableName() string
	// Selectows returns the selectors.
	Selectors() query.Selectors
	// Columns returns the columns.
	Columns() []Column
	// LookupColumn returns the column by the specified name.
	LookupColumn(name string) (Column, error)
}

Schema represents a schema interface in a resultset.

func NewSchema

func NewSchema(opts ...SchemaOption) Schema

NewSchema returns a new resultsetSchema.

func NewSchemaFrom

func NewSchemaFrom(db query.Database, schema query.Schema) Schema

NewSchemaFrom returns a new resultset schema from the specified schema.

type SchemaOption added in v1.4.2

type SchemaOption func(*schema)

SchemaOption represents a functional option for resultsetSchema.

func WithSchemaColumns added in v1.4.2

func WithSchemaColumns(columns []Column) SchemaOption

WithSchemaColumns returns a functional option for resultsetSchema.

func WithSchemaDatabaseName

func WithSchemaDatabaseName(name string) SchemaOption

WithSchemaDatabaseName returns a functional option for resultsetSchema.

func WithSchemaTableName

func WithSchemaTableName(name string) SchemaOption

WithSchemaTableName returns a functional option for resultsetSchema.

Jump to

Keyboard shortcuts

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