db

package
v0.0.0-...-db4e6ed Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2018 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package db module configures a database connection for the application.

Developers use this module by importing and calling db.Init(). A "Transactional" controller type is provided as a way to import interceptors that manage the transaction

In particular, a transaction is begun before each request and committed on success. If a panic occurred during the request, the transaction is rolled back. (The application may also roll the transaction back itself.)

Index

Constants

This section is empty.

Variables

View Source
var (
	Db     *sql.DB
	Driver string
	Spec   string
)

Database connection variables

Functions

func Init

func Init()

Init method used to initialize DB module on `OnAppStart`

Types

type Transactional

type Transactional struct {
	*revel.Controller
	Txn *sql.Tx
}

Transactional definition for database transaction

func (*Transactional) Begin

func (c *Transactional) Begin() revel.Result

Begin a transaction

func (*Transactional) Commit

func (c *Transactional) Commit() revel.Result

Commit the transaction.

func (*Transactional) Rollback

func (c *Transactional) Rollback() revel.Result

Rollback if it's still going (must have panicked).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL