database

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 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 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

type Store added in v1.1.0

type Store struct {
	// contains filtered or unexported fields
}

Store wraps a *sql.DB and provides log operations.

func NewStore added in v1.1.0

func NewStore() *Store

NewStore creates a Store using the connection established by Connect.

func (*Store) GetLogs added in v1.1.0

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

GetLogs retrieves log entries with optional filtering and pagination.

func (*Store) InsertLog added in v1.1.0

func (s *Store) InsertLog(logEntry models.Log) (int, error)

InsertLog inserts a new log entry and returns its ID.

func (*Store) ListenForLogs added in v1.1.0

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

ListenForLogs subscribes to PostgreSQL NOTIFY on log_channel and forwards each notification as a Log to ch. The goroutine stops and closes ch when ctx is cancelled.

Jump to

Keyboard shortcuts

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