dbsession

package
v0.0.0-...-a6c8cb9 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBSession

type DBSession interface {

	/*
		Start a new transaction.  A transaction is a resource overhead and the caller should
		call Close() when it's finished to release this resource.
	*/
	StartTransaction() (*gorp.Transaction, error)

	// Close the DBSession and release the resources associated with it.
	Close()

	/*
		FindAllPeople() gets all records in the people table (whether valid or not) and returns a
		pointer to a slice containing them.  The method does not create an explicit transaction.
	*/
	FindAllPeople() ([]personModel.Person, error)

	/*
	 FindPersonByid fetches the row from the people table with the given uint64 id. The
	 data fetched may or may not be valid.  The method returns a Person containing
	 that data, or an error message.
	*/
	FindPersonByID(id uint64) (personModel.Person, error)
}

DBSession represents a database session.

func MakeGorpMysqlDBSession

func MakeGorpMysqlDBSession() (DBSession, error)

MakeGorpMysqlDBSession is a factory function that creates a GorpMysqlDBSession and returns it as a pointer to a DBSession.

type GorpMysqlDBSession

type GorpMysqlDBSession struct {
	// contains filtered or unexported fields
}

The GorpMysqlDBSession type represents a MySQL database session accessed via GORP. It satisfies the DBSession interface.

func (GorpMysqlDBSession) Close

func (dbs GorpMysqlDBSession) Close()

Close closes the GORP DBMap and releases the database connection. Anything that opens a connection should call this method to close it.

func (GorpMysqlDBSession) FindAllPeople

func (dbs GorpMysqlDBSession) FindAllPeople() ([]personModel.Person, error)

FindAllPeople returns a slice of all valid Person records from the database in a (possibly empty) slice. If the database lookup fails, the error is returned instead.

func (GorpMysqlDBSession) FindPersonByID

func (dbs GorpMysqlDBSession) FindPersonByID(id uint64) (personModel.Person, error)

FindPersonByID fetches the row from the people table with the given uint64 id. The data fetched may or may not be valid. The method returns a Person containing that data, or an error message.

func (GorpMysqlDBSession) StartTransaction

func (dbs GorpMysqlDBSession) StartTransaction() (*gorp.Transaction, error)

StartTransaction starts a transaction.

Jump to

Keyboard shortcuts

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