-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
47 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package edgedb_test | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
edgedb "github.com/edgedb/edgedb-go/internal/client" | ||
) | ||
|
||
// Transactions can be executed using the Tx() method. Note that queries are | ||
// executed on the Tx object. Queries executed on the client in a transaction | ||
// callback will not run in the transaction and will be applied immediately. In | ||
// edgedb-go the callback may be re-run if any of the queries fail in a way | ||
// that might succeed on subsequent attempts. Transaction behavior can be | ||
// configured with TxOptions and the retrying behavior can be configured with | ||
// RetryOptions. | ||
func ExampleTx() { | ||
ctx := context.Background() | ||
client, err := edgedb.CreateClient(ctx, edgedb.Options{}) | ||
|
||
err = client.Tx(ctx, func(ctx context.Context, tx *edgedb.Tx) error { | ||
return tx.Execute(ctx, "INSERT User { name := 'Don' }") | ||
}) | ||
|
||
if err != nil { | ||
log.Println(err) | ||
} | ||
} |