storage

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2020 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UseTransaction

func UseTransaction(container service.Container, fn HandlerFunc) (err error)

UseTransaction executes a HandlerFunc within a storage transaction

Types

type Entity added in v0.4.0

type Entity struct {
	ID        uint           `gorm:"primarykey" json:"id"`
	CreatedAt time.Time      `json:"-"`
	UpdatedAt time.Time      `json:"-"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}

Entity stored in the database

type Entry

type Entry interface {
	GetID() interface{}
}

Entry of a storage entity.

type HandlerFunc

type HandlerFunc func(tx *Transaction) (err error)

HandlerFunc is to be handled by a storage transaction

type Manager

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

Manager of storage

func NewManager

func NewManager(connection gorm.Dialector, container service.Container) (m *Manager, err error)

NewManager consructor

type Model

type Model struct{}

Model embeddable struct for database models (embedd this in your model struct)

func (*Model) Delete

func (m *Model) Delete(tx *Transaction, entry interface{}) (err error)

Delete some existing data entry

func (*Model) Insert

func (m *Model) Insert(tx *Transaction, entry interface{}) (err error)

Insert data entry to database

func (*Model) Remove

func (m *Model) Remove(tx *Transaction, entry interface{}) (err error)

Remove (completely) some existing data entry

func (*Model) Update

func (m *Model) Update(tx *Transaction, entry interface{}) (err error)

Update some existing data entry

type Transaction

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

Transaction for a storage action

func Begin

func Begin(co service.Container) (tx *Transaction, err error)

Begin a transaction

func (*Transaction) Commit

func (tx *Transaction) Commit() (err error)

Commit a transaction

func (*Transaction) Rollback

func (tx *Transaction) Rollback() (err error)

Rollback a transaction

func (*Transaction) Tx

func (tx *Transaction) Tx() *gorm.DB

Tx returns the gorm transaction

Jump to

Keyboard shortcuts

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