Documentation
¶
Index ¶
- func RunConcurrently(many []Runnable, ctx context.Context, able Queryable) error
- func RunPooled(many []Runnable, ctx context.Context, able Queryable, poolSize int) error
- func RunSequential(many []Runnable, ctx context.Context, able Queryable) error
- type Query
- type Queryable
- type Runnable
- type Runner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunConcurrently ¶
Runs a list of queries at the same time. If any of them errors it will try to stop all other queries and return as soon as possible.
Types ¶
type Query ¶
type Query[R any] struct { // The query, sql statements, or the stored procedure to query/execute. Query string // If the query will be called multiple times setting this to true // will generate a reusable prepared statement that will be used for // subsequent runs. Prepared bool // The named input variables In map[string]any // The output variables Out map[string]any // The position input variables InArgs []any // The position output variables OutArgs []any // Creates a row to be populated. This may be necessary for complex // types with pointers, slices, maps, etc. Create func() R // Where to place the rows received. The presense of this field // indicates that rows should be requested and parsed. Results func(result R, index int) bool // Where to place a single result row. The presense of this field // indicates that a row should be requested and parsed. Result *R // How many rows were affected on the last query run. RowsAffected int64 // The ID of the last inserted record on the last query run. LastID int64 // The columns returned from a query Columns []*sql.ColumnType // contains filtered or unexported fields }
A query to run against a database. For stored procedures the query is the stored procedure name. If Prepared is true the query will generated a prepared statement on the first run. If Results or Result is given those values are populated, otherwise the query is executed and RowsAffected and LastID could be updated.
func (Query[R]) GetValues ¶
Gets the references to values in the given row based on the columns prepped.
func (*Query[R]) SetColumns ¶
func (q *Query[R]) SetColumns(columns []*sql.ColumnType)
Preps the query for receiving rows with the given columns
type Queryable ¶ added in v0.2.0
type Queryable interface { ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row }
An interface that covers a connection or transaction
Click to show internal directories.
Click to hide internal directories.