db

package
v0.0.0-...-1a91022 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	// GetProjects returns a list of projects.
	GetProjects() []model.Project
	// GetProject returns a project by its ID.
	GetProject(uint) *model.Project
	// GetVersionsForProjects returns the available version for a given project.
	GetVersionsForProjects(uint) []model.ProjectVersion
	// GetConnector returns the connector for a project.
	// TODO: result should be an enum
	GetConnector(string) string
}

DB is the interface to implement to access the projects and other entites.

type GormDB

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

GormDB is one database implementation

func NewGorm

func NewGorm(cfg *config.Config) (*GormDB, error)

NewGorm creates and configures a gorm compliant database.

func (*GormDB) GetConnector

func (g *GormDB) GetConnector(project string) string

GetConnector returns the connector for a project.

func (*GormDB) GetProject

func (g *GormDB) GetProject(id uint) model.Project

func (*GormDB) GetProjects

func (g *GormDB) GetProjects() []model.Project

func (*GormDB) GetVersionsForProjects

func (g *GormDB) GetVersionsForProjects(id uint) []model.ProjectVersion

type MockDB

type MockDB struct{}

MockDB used for testing purposes.

func (*MockDB) GetConnector

func (m *MockDB) GetConnector(project string) string

GetConnector returns the connector for a project.

func (*MockDB) GetProject

func (m *MockDB) GetProject(id uint) *model.Project

func (*MockDB) GetProjects

func (m *MockDB) GetProjects() []model.Project

func (*MockDB) GetVersionsForProjects

func (m *MockDB) GetVersionsForProjects(id uint) []model.ProjectVersion

GetVersionsForProjects returns the available version for a given project.

Jump to

Keyboard shortcuts

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