db

package
v0.0.0-...-ccb81e8 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 17 Imported by: 0 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

View Source
var Monitor = newMonitor()

Functions

func BulkInsert

func BulkInsert[T Table](executor gorp.SqlExecutor, db DB, allObjs ...T) error

Bulk insert objects into the database, using an executor which can be a transaction or a database connection itself.

Note: This function does NOT support auto-incrementing primary keys.

func ReplaceAll

func ReplaceAll[T Table](db DB, objs ...T) error

Replace all old objects of a table with new objects.

Types

type Connector

type Connector struct{ client.Client }

Kubernetes connector which initializes the database connection from a secret.

func (Connector) FromSecretRef

func (c Connector) FromSecretRef(ctx context.Context, ref corev1.SecretReference) (*DB, error)

Create a new database client with authentication from the provided secret reference.

type DB

type DB struct {
	*gorp.DbMap
	// contains filtered or unexported fields
}

Wrapper around gorp.DbMap that adds some convenience functions.

func (*DB) AddTable

func (d *DB) AddTable(t Table) *gorp.TableMap

Adds a Model table to the database.

func (*DB) CreateTable

func (d *DB) CreateTable(table ...*gorp.TableMap) error

Adds missing functionality to gorp.DbMap which creates one table.

func (*DB) SelectTimed

func (d *DB) SelectTimed(group string, i any, query string, args ...any) ([]any, error)

Executes a select query while monitoring its execution time.

func (*DB) TableExists

func (d *DB) TableExists(t Table) bool

Check if a table exists in the database.

type Table

type Table interface {
	TableName() string
	// Map of index name to column names.
	Indexes() map[string][]string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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