database

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *sql.DB

DB is the database connection

Functions

func Close

func Close()

Close closes the database connection

func Connect

func Connect() error

Connect establishes a connection to the PostgreSQL database

func GetLogs

func GetLogs(filter models.LogFilter) ([]models.Log, error)

GetLogs retrieves logs from the database with optional filtering

func InsertLog

func InsertLog(logEntry models.Log) (int, error)

InsertLog inserts a new log entry into the database

func ListenForLogs

func ListenForLogs(ctx context.Context, logChan chan<- models.Log) error

ListenForLogs listens for new log notifications and sends them to the provided channel

func SetupMockDB

func SetupMockDB() (*sql.DB, sqlmock.Sqlmock, error)

SetupMockDB sets up a mock database for testing

Types

type AnyTime

type AnyTime struct{}

AnyTime is a custom matcher for timestamp

func (AnyTime) Match

func (a AnyTime) Match(v driver.Value) bool

Match satisfies sqlmock.Argument interface

Jump to

Keyboard shortcuts

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