db

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	// Conn is the underlying GORM database connection.
	Conn *gorm.DB
}

Database represents a wrapper around the GORM database connection.

func InitDB

func InitDB(cfg *config.Config) (*Database, error)

InitDB initializes and returns a new Database instance.

It takes a configuration object and uses it to establish a connection to the PostgreSQL database. It also performs auto-migration of the database schema for the Repository, WorkflowRun, and Statistics models.

Parameters:

  • cfg: A pointer to a config.Config struct containing database connection details.

Returns:

  • A pointer to a Database struct containing the initialized GORM DB connection.
  • An error if the database connection or auto-migration fails.

func (*Database) GetMonitoredRepositories

func (db *Database) GetMonitoredRepositories() ([]models.Repository, error)

func (*Database) SaveStatistics

func (db *Database) SaveStatistics(stats *models.Statistics) error

func (*Database) SaveUser

func (db *Database) SaveUser(user *models.GitHubUser) error

func (*Database) SaveWorkflowRun

func (db *Database) SaveWorkflowRun(run *github.WorkflowRun) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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