Created
April 26, 2021 11:52
-
-
Save dipeshhkc/89e91e9fa71a7ae0e47264f5ce8d85c9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// begin a transaction | |
tx := db.Begin() | |
// do some database operations in the transaction (use 'tx' from this point, not 'db') | |
tx.Create(...) | |
// ... | |
// rollback the transaction in case of error | |
tx.Rollback() | |
// Or commit the transaction | |
tx.Commit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment