db

package
v0.0.0-...-ffdcb7f Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2019 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CountQuery

type CountQuery interface {

	// Count returns the number of rows in the given table.
	Count(database.Tx, string, string, ...interface{}) (int, error)
}

CountQuery defines queries to the database for count queries

type Node

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

Node mediates access to the data stored in the node-local SQLite database.

func (*Node) Close

func (n *Node) Close() error

Close the database facade.

func (*Node) Transaction

func (n *Node) Transaction(f func(*NodeTx) error) error

Transaction creates a new NodeTx object and transactionally executes the node-level database interactions invoked by the given function. If the function returns no error, all database changes are committed to the node-level database, otherwise they are rolled back.

type NodeTransactioner

type NodeTransactioner interface {

	// Transaction creates a new NodeTx object and transactionally executes the
	// node-level database interactions invoked by the given function. If the
	// function returns no error, all database changes are committed to the
	// node-level database, otherwise they are rolled back.
	Transaction(f func(*NodeTx) error) error
}

NodeTransactioner represents a way to run transaction on the node

type NodeTx

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

NodeTx models a single interaction with a node-local database.

It wraps low-level db.Tx objects and offers a high-level API to fetch and update data.

func NewNodeTx

func NewNodeTx(tx database.Tx) *NodeTx

NewNodeTx creates a new transaction node with sane defaults

type ObjectsQuery

type ObjectsQuery interface {
	// SelectObjects executes a statement which must yield rows with a specific
	// columns schema. It invokes the given Dest hook for each yielded row.
	SelectObjects(database.Tx, query.Dest, string, ...interface{}) error

	// UpsertObject inserts or replaces a new row with the given column values,
	// to the given table using columns order. For example:
	//
	// UpsertObject(tx, "cars", []string{"id", "brand"}, []interface{}{1, "ferrari"})
	//
	// The number of elements in 'columns' must match the one in 'values'.
	UpsertObject(database.Tx, string, []string, []interface{}) (int64, error)

	// DeleteObject removes the row identified by the given ID. The given table
	// must have a primary key column called 'id'.
	//
	// It returns a flag indicating if a matching row was actually found and
	// deleted or not.
	DeleteObject(database.Tx, string, int64) (bool, error)
}

ObjectsQuery defines queries to the database for generic object queries

type Query

type Query interface {
	ObjectsQuery
	StringsQuery
	CountQuery
}

Query defines different queries for accessing the database

type QueryNode

type QueryNode interface {

	// Open the node-local database object.
	Open(string) error

	// EnsureSchema applies all relevant schema updates to the node-local
	// database.
	//
	// Return the initial schema version found before starting the update, along
	// with any error occurred.
	EnsureSchema(hookFn schema.Hook) (int, error)

	// DB return the current database source.
	DB() database.DB
}

QueryNode represents a local node in a cluster

type StringsQuery

type StringsQuery interface {

	// SelectStrings executes a statement which must yield rows with a single
	// string column. It returns the list of column values.
	SelectStrings(database.Tx, string, ...interface{}) ([]string, error)
}

StringsQuery defines queries to the database for string queries

type Transaction

type Transaction interface {
	// Transaction executes the given function within a database transaction.
	Transaction(database.DB, func(database.Tx) error) error
}

Transaction defines a method for executing transactions over the database

Directories

Path Synopsis
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package query implements helpers around database/sql to execute various kinds of very common SQL queries.
Package query implements helpers around database/sql to execute various kinds of very common SQL queries.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package schema offers utilities to create and maintain a database schema.
Package schema offers utilities to create and maintain a database schema.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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