Documentation ¶
Index ¶
- func RunConcurrently(many []Runnable, ctx context.Context, conn *sql.Conn) error
- func RunPooled(many []Runnable, ctx context.Context, conn *sql.Conn, poolSize int) error
- func RunSequential(many []Runnable, ctx context.Context, conn *sql.Conn) error
- type Query
- type QueryResult
- type QuerySlice
- type Runnable
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 input variables In map[string]any // The output variables Out map[string]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 QueryResult[R] // 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 // 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 ¶
Preps the query for receiving rows with the given columns
type QueryResult ¶
A type that can receive rows from a query.
type QuerySlice ¶
A QueryResult for a slice.
func (*QuerySlice[R]) Add ¶
func (st *QuerySlice[R]) Add(result R) bool