database

package
v0.7.57 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const Postgres = "postgres"
View Source
const Sqlite = "sqlite3"

Variables

This section is empty.

Functions

func NewMigrationRunner

func NewMigrationRunner(databaseConnection *DBConnection) (*migrate.Migrate, error)

func ReplacePlaceholders added in v0.2.2

func ReplacePlaceholders(query string) string

ReplacePlaceholders replaces each '?' in the input string with $1, $2, ..., $n

Types

type DBConnection

type DBConnection struct {
	ConnType string
	// contains filtered or unexported fields
}

func Connect

func Connect(connStr string) (*DBConnection, error)

func (*DBConnection) Insert

func (dbc *DBConnection) Insert(sql string, parameters ...any) error

func (*DBConnection) MigrateUp

func (dbc *DBConnection) MigrateUp() error

func (*DBConnection) Query

func (dbc *DBConnection) Query(ctx context.Context, rowMapper func(scan func(dest ...any) error) (bool, error), sql string, parameters ...any) error

Query the database and map the results using the provided rowMapper function. The rowMapper function gets the sql.Rows#Scan method as an argument, if it returns false, the loop will break, the same if it returns an error.

Jump to

Keyboard shortcuts

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