clean up wording in README

made the paragraph about transactions in callbacks more straightforward
This commit is contained in:
Levin Alexander 2015-12-18 11:50:11 +01:00
parent e541ca5cdf
commit 2f85c0e4d6
1 changed files with 4 additions and 4 deletions

View File

@ -1064,10 +1064,10 @@ func (u *User) AfterCreate() (err error) {
}
```
As you know, save/delete operations in gorm are running in a transaction,
This is means if changes made in the transaction is not visiable unless it is commited,
So if you want to use those changes in your callbacks, you need to run SQL in same transaction.
Fortunately, gorm support pass transaction to callbacks as you needed, you could do it like this:
Save/delete operations in gorm are running in a transaction.
Changes made in that transaction are not visible unless it is commited.
So if you want to use those changes in your callbacks, you need to run your SQL in the same transaction.
For this Gorm supports passing transactions to callbacks like this:
```go
func (u *User) AfterCreate(tx *gorm.DB) (err error) {