db

package
v0.0.0-...-60192f8 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package db provides the first layer interfaces to database storage.

Index

Constants

This section is empty.

Variables

View Source
var UnaccentCompare = unicodeCollate.CompareString

UnaccentCompare performs a string comparison after removing accents.

Functions

func Close

func Close() error

Close closes the connection to the database.

func DB

func DB() *sql.DB

DB returns the current sql.DB instance.

func Init

func Init() error

Init creates the database schema by running all the needed migrations.

func InsertWithID

func InsertWithID(stmt *goqu.InsertDataset, r string) (id int, err error)

InsertWithID executes an insert statement and returns the value of the field given by "r". Depending on the database, it uses different ways to do just that.

func Open

func Open(dsn string) error

Open opens a database connection and sets internal variables that can be retrieved using DB() (holding the sql.DB reference) and Q() (holding the goqu.Database reference).

func Q

func Q() *goqu.Database

Q returns the current goqu.Database instance.

Types

type Connector

type Connector interface {
	// Name returns the connector's name
	Name() string

	// Dialect returns the connector's dialect
	Dialect() string

	// Open creates a new db connection.
	Open(*url.URL) (*sql.DB, error)

	// HasTable checks if a given table exists in the
	// database. It's used by the migration system.
	HasTable(string) (bool, error)
}

Connector is an interface for a database connector.

func Driver

func Driver() Connector

Driver returns the SQL driver in use.

Directories

Path Synopsis
Package filters provides query filters for specific operations.
Package filters provides query filters for specific operations.
Package types provides some shared database types.
Package types provides some shared database types.

Jump to

Keyboard shortcuts

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