database

package
v0.0.2-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 13 Imported by: 1 module, 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 Builder = squirrel.StatementBuilder.PlaceholderFormat(squirrel.Dollar)

Builder is a global instance of the sql builder. we are able to hardcode to postgres since sqlite3 is compatible with postgres.

Functions

func Connect

func Connect(ctx context.Context, driver string, datasource string) (*sqlx.DB, error)

Connect to a database and verify with a ping.

func ConnectAndMigrate

func ConnectAndMigrate(ctx context.Context, driver string, datasource string, migrator Migrator) (*sqlx.DB, error)

ConnectAndMigrate creates the database handle and migrates the database.

func Limit

func Limit(size int) uint64

limit returns the page size to a sql limit.

func Must

func Must(db *sqlx.DB, err error) *sqlx.DB

Must is a helper function that wraps a call to Connect and panics if the error is non-nil.

func Offset

func Offset(page, size int) uint64

offset converts the page to a sql offset.

func ProcessSQLErrorf

func ProcessSQLErrorf(ctx context.Context, err error, format string, args ...interface{}) error

Logs the error and message, returns either the provided message. Always logs the full message with error as warning.

Types

type Config

type Config struct {
	Driver     string
	Datasource string
}

Config specifies the config for the database package.

type Migrator

type Migrator func(ctx context.Context, dbx *sqlx.DB) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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