database

package
v0.0.0-...-8d7bd48 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package database provides support for access the database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNoRowError

func IsNoRowError(err error) bool

IsNoRowError checks if the error is caused by no row found in the database.

func IsUniqueViolationError

func IsUniqueViolationError(err error) bool

IsUniqueViolationError chec if the error code is 23505: https://www.postgresql.org/docs/current/static/errcodes-appendix.html

func Open

func Open(cfg Config) (*bun.DB, error)

Open knows how to open a database connection based on the configuration.

func StatusCheck

func StatusCheck(ctx context.Context, db *bun.DB) error

StatusCheck returns nil if it can successfully talk to the database. It returns a non-nil error otherwise.

Types

type Config

type Config struct {
	User       string
	Password   string
	Host       string
	Name       string
	DisableTLS bool
}

Config is the required properties to use the database.

func (*Config) String

func (cfg *Config) String() string

String returns a string representation of the database configuration.

Jump to

Keyboard shortcuts

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