Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Transaction ¶
func Transaction(b *gorp.DbMap, f TransactionFunc) error
Transaction wraps your calls in a gorp.Transaction. If the call should fail with an error it will perform a rollback. Otherwise the transaction will be committed.
Usage: ``` import (
dblib "github.com/chef/automate/lib/db" "github.com/go-gorp/gorp" _ "github.com/lib/pq"
)
type postgres struct { *gorp.DbMap }
func (db *postgres) InsertData(data) error { return dblib.Transaction(db.DbMap, func(tx *gorp.Transaction) error { // Add here all your transactions (check all errors) tx.Insert(deploy) tx.Update(deploy) tx.Insert(deploy) tx.Delete(deploy) return nil }) }
```
Types ¶
Click to show internal directories.
Click to hide internal directories.