repositories

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Copyright (C) 2024 Tim Bastin, l3montree UG (haftungsbeschränkt)

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAffectedComponentRepository added in v0.5.1

func NewAffectedComponentRepository(db core.DB) *affectedCmpRepository

func NewAssetRepository

func NewAssetRepository(db core.DB) *assetRepository

func NewCVERepository

func NewCVERepository(db database.DB) *cveRepository

func NewCWERepository

func NewCWERepository(db core.DB) *cweRepository

func NewComponentRepository

func NewComponentRepository(db database.DB) *componentRepository

func NewConfigRepository

func NewConfigRepository(db core.DB) *configRepository

func NewExploitRepository

func NewExploitRepository(db core.DB) *exploitRepository

func NewFlawEventRepository

func NewFlawEventRepository(db core.DB) *eventRepository

func NewFlawRepository

func NewFlawRepository(db core.DB) *flawRepository

func NewGithubAppInstallationRepository

func NewGithubAppInstallationRepository(db core.DB) *githubAppInstallationRepository

func NewGithubUserRepository added in v0.5.1

func NewGithubUserRepository(db core.DB) *githubUserRepository

func NewOrgRepository

func NewOrgRepository(db core.DB) *orgRepository

func NewPATRepository

func NewPATRepository(db core.DB) *gormPatRepository

func NewProjectRepository

func NewProjectRepository(db core.DB) *projectRepository

Types

type BatchModelWriter

type BatchModelWriter[T Tabler, Tx any] interface {
	CreateBatch(tx Tx, ts []T) error
	SaveBatch(tx Tx, ts []T) error
}

type GormRepository

type GormRepository[ID comparable, T Tabler] struct {
	// contains filtered or unexported fields
}

func (*GormRepository[ID, T]) Begin

func (g *GormRepository[ID, T]) Begin() *gorm.DB

func (*GormRepository[ID, T]) Create

func (g *GormRepository[ID, T]) Create(tx *gorm.DB, t *T) error

func (*GormRepository[ID, T]) CreateBatch

func (g *GormRepository[ID, T]) CreateBatch(tx *gorm.DB, ts []T) error

func (*GormRepository[ID, T]) Delete

func (g *GormRepository[ID, T]) Delete(tx *gorm.DB, id ID) error

func (*GormRepository[ID, T]) GetDB

func (g *GormRepository[ID, T]) GetDB(tx *gorm.DB) *gorm.DB

func (*GormRepository[ID, T]) List

func (g *GormRepository[ID, T]) List(ids []ID) ([]T, error)

func (*GormRepository[ID, T]) Read

func (g *GormRepository[ID, T]) Read(id ID) (T, error)

func (*GormRepository[ID, T]) Save

func (g *GormRepository[ID, T]) Save(tx *gorm.DB, t *T) error

func (*GormRepository[ID, T]) SaveBatch

func (g *GormRepository[ID, T]) SaveBatch(tx *gorm.DB, ts []T) error

func (*GormRepository[ID, T]) Transaction

func (g *GormRepository[ID, T]) Transaction(f func(tx *gorm.DB) error) error

type ModelReader

type ModelReader[ID any, T Tabler] interface {
	Read(id ID) (T, error)
	List(ids []ID) ([]T, error)
}

type ModelWriter

type ModelWriter[ID any, T Tabler, Tx any] interface {
	Create(tx Tx, t *T) error
	Save(tx Tx, t *T) error

	Delete(tx Tx, id ID) error
}

type Repository

type Repository[ID any, T Tabler, Tx any] interface {
	ModelWriter[ID, T, Tx]
	ModelReader[ID, T]
	BatchModelWriter[T, Tx]
	Transactioner[Tx]
}

type Tabler

type Tabler interface {
	TableName() string
}

type Transactioner

type Transactioner[Tx any] interface {
	Transaction(func(tx Tx) error) error
	GetDB(tx Tx) Tx
	Begin() Tx
}

Jump to

Keyboard shortcuts

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