persistence

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(ctx context.Context, p Prepared, dialect goqu.DialectWrapper, dc DatabaseCreate) error

Create is a general solution for adding values to a Prepared implementation

func Select

func Select(ctx context.Context, q Query, dialect goqu.DialectWrapper, ds DatabaseSelect, where ...exp.Expression) error

Select is a general solution for getting data from a Query implementation

func Update

func Update(ctx context.Context, p Prepared, dialect goqu.DialectWrapper, du DatabaseUpdate) error

Update is a general solution for updating values to a Prepared implementation

Types

type DatabaseCreate

type DatabaseCreate struct {
	Fields           []interface{}
	Values           []interface{}
	ReturningColumns []interface{}
	Receivers        []interface{}
	Table            string
}

DatabaseCreate is the result of a Storable call

type DatabaseSelect

type DatabaseSelect struct {
	Fields    []interface{}
	Receivers []interface{}
	Table     string
}

DatabaseSelect is the result of a Selectable call

type DatabaseUpdate

type DatabaseUpdate struct {
	Records map[string]interface{}
	Where   []exp.Expression
	Table   string
}

DatabaseUpdate is the result of a Updatable call

type Prepared

type Prepared interface {
	PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
}

Prepared is a definition for anything implement the PrepareContext. This can be a single database statement or a database transaction statement as well.

type Query

type Query interface {
	QueryContext(ctx context.Context, query string, elements ...interface{}) (*sql.Rows, error)
}

Query is a definition for anything implement the PrepareContext. This can be a single database statement or a database transaction statement as well.

type Selectable

type Selectable interface {
	Select(opts ...interface{}) (DatabaseSelect, error)
}

Selectable defines whether a struct can be retrieved from the database

type Storable

type Storable interface {
	Create(transactionID string) (DatabaseCreate, error)
}

Storable defines whether a struct can be persisted to database or not

type Updatable

type Updatable interface {
	Update(transactionID string) (DatabaseUpdate, error)
}

Updatable defines whether a struct can be updated if it's already exists in the database

Jump to

Keyboard shortcuts

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