Introduction
Bob's Executor is an interface that looks like this.
type Executor interface {
QueryContext(ctx context.Context, query string, args ...any) (scan.Rows, error)
ExecContext(context.Context, string, ...any) (sql.Result, error)
}
This executor is used to run queries
📄️ Bob Executors
Understanding the Bob Excecutor Types
📄️ Exec
Execute a query without returning any rows.
📄️ One
Executes a query and return a single concrete type
📄️ All
Execute a query and return a slice of objects.
📄️ Cursor
Execute a query and returns a cursor that yields a defined struct per row
📄️ Prepare
Creates a prepared statement for later queries or executions.
📄️ Why not *sql.DB?
Why Bob uses a custom executor interface