Exemple #1
0
// Begin a transaction.
func (p DbPlugin) BeforeRequest(c *revel.Controller) {
	txn, err := Db.Begin()
	if err != nil {
		panic(err)
	}
	c.Txn = txn
}
Exemple #2
0
// Commit the active transaction.
func (p DbPlugin) AfterRequest(c *revel.Controller) {
	if err := c.Txn.Commit(); err != nil {
		if err != sql.ErrTxDone {
			panic(err)
		}
	}
	c.Txn = nil
}