db

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: May 23, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package db provides database connectivity and operations

Index

Constants

View Source
const (
	// DefaultHost is the default database host
	DefaultHost = "localhost"
	// DefaultPort is the default database port
	DefaultPort = 5432
	// DefaultUser is the default database user
	DefaultUser = "postgres"
	// DefaultPassword is the default database password
	DefaultPassword = "postgres"
	// DefaultDBName is the default database name
	DefaultDBName     = "postgres"
	DefaultSSLEnabled = false
)

Database configuration constants

Variables

This section is empty.

Functions

func IsDuplicateKeyError

func IsDuplicateKeyError(err error) bool

IsDuplicateKeyError checks if the given error is a PostgreSQL duplicate key error

func New

func New(opts Options) (*gorm.DB, error)

New creates a new database connection with the given options

Types

type Options

type Options struct {
	Host       string
	User       string
	Password   string
	DBName     string
	Port       int
	SSLEnabled *bool
	LogLevel   logger.LogLevel
}

Options represents database connection configuration options

Directories

Path Synopsis
Package models contains database models and related utility functions
Package models contains database models and related utility functions
Package repos provides repository implementations for database operations
Package repos provides repository implementations for database operations

Jump to

Keyboard shortcuts

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