pgsql

package
v0.0.18-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2025 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package psql provides utility functions for working with Postgre in the context of a knowledge database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BatchUpdateOsv

func BatchUpdateOsv(db *bun.DB, osvItems []knowledge.OSVItem) error

BatchUpdateOsv performs efficient batch upsert operations for multiple OSV records. This is significantly more efficient than individual updates when processing many records.

func GetOsvByID

func GetOsvByID(db *bun.DB, osvId string) (*knowledge.OSVItem, error)

GetOsvByID retrieves an OSV record by its OSV ID.

func UpdateCWE

func UpdateCWE(db *bun.DB, cwes []knowledge.CWEEntry) error

UpdateCWE updates the CWE (Common Weakness Enumeration) entries in the graph database. It takes a graph driver and a slice of CWEEntry structs as input. For each CWEEntry in the slice, it tries to update the corresponding document in the "CWE" vertex collection. If the document exists and is successfully updated, it generates a changelog and creates a new document in the "REVISIONS" vertex collection. If the document doesn't exist, it creates a new document in the "CWE" vertex collection. Returns an error if any operation fails.

func UpdateEPSS

func UpdateEPSS(db *bun.DB, epssScores []knowledge.EPSS) error

UpdateCWE updates the CWE (Common Weakness Enumeration) entries in the graph database. It takes a graph driver and a slice of CWEEntry structs as input. For each CWEEntry in the slice, it tries to update the corresponding document in the "CWE" vertex collection. If the document exists and is successfully updated, it generates a changelog and creates a new document in the "REVISIONS" vertex collection. If the document doesn't exist, it creates a new document in the "CWE" vertex collection. Returns an error if any operation fails.

func UpdateLicenses

func UpdateLicenses(db *bun.DB, licenses []knowledge.License) error

func UpdateNvd

func UpdateNvd(db *bun.DB, nvd []knowledge.NVDItem) error

func UpdateOsv

func UpdateOsv(db *bun.DB, osv knowledge.OSVItem) error

UpdateOsv updates or inserts an OSV document using an efficient upsert operation. This replaces the inefficient check-then-act pattern with a single atomic operation.

func UpdatePackage

func UpdatePackage(db *bun.DB, pack knowledge.Package) error

UpdatePackage updates a package in the specified graph with the given package information. It takes the graph, package details, and language as input parameters. If the package key is empty, it returns an error. If the package already exists in the graph, it updates the package and creates a revision document with the changelog. If the package doesn't exist, it creates a new package document. It also updates the versions of the package and creates edge documents to link the package with its versions. Returns an error if any operation fails.

Types

This section is empty.

Jump to

Keyboard shortcuts

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