dbutil

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMalformedEntity indicates a malformed entity specification.
	ErrMalformedEntity = errors.New("malformed entity specification")

	// ErrNotFound indicates that an entity was not found in the database.
	ErrNotFound = errors.New("entity not found")

	// ErrConflict indicates that entity an entity with conflicting properties already exists.
	ErrConflict = errors.New("entity already exists")

	// ErrCreateEntity indicates an error in attempting to create an entity or entities.
	ErrCreateEntity = errors.New("failed to create entity")

	// ErrRetrieveEntity indicates an error in attempting to retrieve an entity or entities.
	ErrRetrieveEntity = errors.New("failed to retrieve entity")

	// ErrUpdateEntity indicates an error in attempting to update an entity or entities.
	ErrUpdateEntity = errors.New("failed to update entity")

	// ErrRemoveEntity indicates an error in attempting to remove an entity or entities.
	ErrRemoveEntity = errors.New("failed to remove entity")

	// ErrScanMetadata indicates an error in attempting to decode entity metadata from the database.
	ErrScanMetadata = errors.New("failed to scan metadata from db")
)

Functions

func BuildWhereClause added in v0.26.0

func BuildWhereClause(filters ...string) string

func CreateSpan added in v0.30.1

func CreateSpan(ctx context.Context, tracer opentracing.Tracer, opName string) opentracing.Span

func GetDirQuery

func GetDirQuery(dir string) string

func GetGroupIDsQuery added in v0.30.0

func GetGroupIDsQuery(ids []string) string

func GetMetadataQuery

func GetMetadataQuery(m map[string]interface{}) (mb []byte, mq string, err error)

func GetNameQuery

func GetNameQuery(name string) (string, string)

func GetOffsetLimitQuery added in v0.24.0

func GetOffsetLimitQuery(limit uint64) string

func GetOrderQuery

func GetOrderQuery(order string) string

func GetPayloadQuery added in v0.28.3

func GetPayloadQuery(m map[string]interface{}) (mb []byte, mq string, err error)

func Total added in v0.26.0

func Total(ctx context.Context, db Database, query string, params interface{}) (uint64, error)

Types

type Database added in v0.26.0

type Database interface {
	NamedExecContext(context.Context, string, interface{}) (sql.Result, error)
	QueryRowxContext(context.Context, string, ...interface{}) *sqlx.Row
	NamedQueryContext(context.Context, string, interface{}) (*sqlx.Rows, error)
	SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	GetContext(context.Context, interface{}, string, ...interface{}) error
	BeginTxx(context.Context, *sql.TxOptions) (*sqlx.Tx, error)
}

Database provides a database interface

func NewDatabase added in v0.26.0

func NewDatabase(db *sqlx.DB) Database

NewDatabase creates a ThingDatabase instance

Jump to

Keyboard shortcuts

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