models

package
v0.0.0-...-3e5594c Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package models contains the data models and database access layer

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionParams

type ConnectionParams struct {
	Host     string
	Port     int
	User     string
	Password string
	DBName   string
	SSLMode  string
	TimeZone string
}

ConnectionParams holds the parameters for connecting to the database

type DB

type DB struct {
	*pgx.Conn
	*gen.Queries
}

DB wraps the database connection and queries

func Connect

func Connect(params ConnectionParams) (*DB, error)

Connect establishes a connection to the database and initializes the global instance

func GetDB

func GetDB() *DB

GetDB returns the globally initialized database instance. It panics if the database is not initialized.

func (*DB) WithTx

func (db *DB) WithTx(ctx context.Context, fn func(*gen.Queries) error) error

WithTx executes a function within a transaction

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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