Skip to content

Latest commit

 

History

History
30 lines (26 loc) · 645 Bytes

transactions.md

File metadata and controls

30 lines (26 loc) · 645 Bytes

Transactions

In order to trigger transaction queries you might need to use BeginTransaction, CommitTransaction or RollbackTransaction methods.

//You trigger begin of transaction
q := new(clients.Query).BeginTransaction()
_, err := client.Execute(q)
if err != nil {
    return err
}

//You run your queries
//....

if err != nil {
	//you handle errors and rollback if needed
	q = new(clients.Query).RollbackTransaction()
    _, err = client.Execute(q)
    if err != nil {
        return err
    }
}

//You commit the changes
q = new(clients.Query).CommitTransaction()
_, err = client.Execute(q)
if err != nil {
    return err
}