db

package
v0.0.0-...-f347ef5 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(cfg *config.Config, logger lumber.Logger) (models.DB, error)

Connect create connection with database

Types

type DB

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

DB is a pool of zero or more underlying connections to the photon database.

func (*DB) Close

func (db *DB) Close() error

Close closes the database connection.

func (*DB) Execute

func (db *DB) Execute(fn func(conn *sqlx.DB) error) (err error)

Execute and executes a function. Any error that is returned from the function is returned from the Execute() method.

func (*DB) ExecuteTransaction

func (db *DB) ExecuteTransaction(fn func(tx *sqlx.Tx) error) (err error)

ExecuteTransaction executes a function within the context of a read-write managed transaction. If no error is returned from the function then the transaction is committed. If an error is returned then the entire transaction is rolled back. Any error that is returned from the function or returned from the commit is returned from the ExecuteTransaction() method.

Jump to

Keyboard shortcuts

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