Closed lsdch closed 3 months ago
This PR introduces the Executor interface which exposes all querying functions that are common to both Client and Tx. Example use-case:
Executor
Client
Tx
func CreateItem(db edgedb.Executor, name string) (item Item, err error) { query := `select (insert Item { name := $0 }) { name };` err = db.QuerySingle(context.Background(), query, &item, name) return } // Using Client client, _ := edgedb.CreateClient(ctx, edgedb.Options{}) CreateItem(client, "Item name") // Using Tx client.Tx(context.Background(), func(ctx context.Context, tx *edgedb.Tx) error { CreateItem(tx, "Item name") // Transaction may then be rolled back, e.g. if this is a unit-test return errors.New("Rollback") })
All commit authors signed the Contributor License Agreement.
You can run the linter locally with make lint & make gendocs-lint.
make lint
make gendocs-lint
Thanks! Linter seems to be happy now :slightly_smiling_face:
This change was released in v0.16.0.
This PR introduces the
Executor
interface which exposes all querying functions that are common to bothClient
andTx
. Example use-case: