persistence

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package persistence simplifies the database interaction by providing helper functions it uses sqlx internally

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleTX

func HandleTX(complete bool, atomic *Atomic, err error) error

HandleTX completes the given transaction if an error is supplied a rollback is performed

Types

type Atomic

type Atomic struct {
	*sqlx.Tx
	Active bool
}

Atomic defines a transactional operation - like the A in ACID https://en.wikipedia.org/wiki/ACID

func CheckTX

func CheckTX(c Connection, a *Atomic) (*Atomic, error)

CheckTX returns a new Atomic object if the supplied object is inactive if the supplied object is active - the same object is returned

type Connection

type Connection struct {
	*sqlx.DB
	Active bool
}

Connection defines a storage/database/... connection

func NewConn

func NewConn(connstr string) Connection

NewConn creates a connection to a store/repository

func NewFromDB

func NewFromDB(db *sqlx.DB) Connection

NewFromDB creates a new connection based on existing DB handle

func (Connection) CreateAtomic

func (c Connection) CreateAtomic() (Atomic, error)

CreateAtomic starts a new transaction

Jump to

Keyboard shortcuts

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