db

package
v0.0.0-...-2971d17 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BooleanFalse string
View Source
var BooleanTrue string
View Source
var CurrentTimestamp string
View Source
var Exec = getExec(db)
View Source
var FnJSONGroupArray string
View Source
var FnJSONObject string
View Source
var NewAdvisoryLock func(names ...string) AdvisoryLock

Functions

func Close

func Close() error

func GetDB

func GetDB() *dbExecutor

func JSONScan

func JSONScan(value any, o any) error

func JSONValue

func JSONValue(o any) (driver.Value, error)

func JoinColumnNames

func JoinColumnNames(columns ...string) string

func JoinPrefixedColumnNames

func JoinPrefixedColumnNames(prefix string, columns ...string) string

func Ping

func Ping()

func PrepareFTS5Query

func PrepareFTS5Query(query string, lenient bool) string

func Query

func Query(query string, args ...any) (*sql.Rows, error)

func QueryRow

func QueryRow(query string, args ...any) *sql.Row

func ToValues

func ToValues[T any](values []T, format string) string

Types

type AdvisoryLock

type AdvisoryLock interface {
	Executor
	GetName() string
	Acquire() bool
	TryAcquire() bool
	Release() bool
	ReleaseAll() bool
	Err() error
}

type CommaSeperatedInt

type CommaSeperatedInt []int

func (*CommaSeperatedInt) Scan

func (csi *CommaSeperatedInt) Scan(value any) error

func (CommaSeperatedInt) Value

func (csi CommaSeperatedInt) Value() (driver.Value, error)

type CommaSeperatedString

type CommaSeperatedString []string

func (*CommaSeperatedString) Scan

func (css *CommaSeperatedString) Scan(value any) error

func (CommaSeperatedString) Value

func (css CommaSeperatedString) Value() (driver.Value, error)

type ConnectionURI

type ConnectionURI struct {
	*url.URL
	DriverName string
	Dialect    DBDialect
}

func ParseConnectionURI

func ParseConnectionURI(connection_uri string) (ConnectionURI, error)

func (ConnectionURI) DSN

func (uri ConnectionURI) DSN(mods ...DSNModifier) string

type DB

type DB struct {
	*sql.DB
	URI ConnectionURI
}

func Open

func Open() *DB

type DBDialect

type DBDialect string
const (
	DBDialectPostgres DBDialect = "postgres"
	DBDialectSQLite   DBDialect = "sqlite"
)
var Dialect DBDialect

type DSNModifier

type DSNModifier func(u *url.URL, q *url.Values)

type DateOnly

type DateOnly struct{ time.Time }

func (DateOnly) IsZero

func (t DateOnly) IsZero() bool

func (*DateOnly) Scan

func (t *DateOnly) Scan(value any) error

func (DateOnly) String

func (t DateOnly) String() string

func (DateOnly) Value

func (t DateOnly) Value() (driver.Value, error)

type Executor

type Executor interface {
	Exec(query string, args ...any) (sql.Result, error)
	Query(query string, args ...any) (*sql.Rows, error)
	QueryRow(query string, args ...any) *sql.Row
}

type JSONIntList

type JSONIntList []int

func (*JSONIntList) Scan

func (list *JSONIntList) Scan(value any) error

func (JSONIntList) Value

func (list JSONIntList) Value() (driver.Value, error)

type JSONStringList

type JSONStringList []string

func (*JSONStringList) Scan

func (list *JSONStringList) Scan(value any) error

func (JSONStringList) Value

func (list JSONStringList) Value() (driver.Value, error)

type NullString

type NullString struct {
	String string
}

func (NullString) Is

func (nv NullString) Is(value string) bool

func (NullString) IsZero

func (nv NullString) IsZero() bool

func (*NullString) Scan

func (nv *NullString) Scan(value any) error

func (NullString) Value

func (nv NullString) Value() (driver.Value, error)

type Timestamp

type Timestamp struct{ time.Time }

func (Timestamp) IsZero

func (t Timestamp) IsZero() bool

func (*Timestamp) Scan

func (t *Timestamp) Scan(value any) error

func (Timestamp) Value

func (t Timestamp) Value() (driver.Value, error)

type Tx

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

func Begin

func Begin() (*Tx, error)

func (*Tx) Commit

func (tx *Tx) Commit() error

func (*Tx) Exec

func (tx *Tx) Exec(query string, args ...any) (sql.Result, error)

func (*Tx) Query

func (tx *Tx) Query(query string, args ...any) (*sql.Rows, error)

func (*Tx) QueryRow

func (tx *Tx) QueryRow(query string, args ...any) *sql.Row

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Jump to

Keyboard shortcuts

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