db

package
v0.81.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package db provides mechanisms for interacting with a database directly

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PostgresClient added in v0.31.0

type PostgresClient struct {
	DB sqlx.DB
}

PostgresClient is a postgres client based on sqlx

func NewPostgresClient added in v0.31.0

func NewPostgresClient(host, database, user, password string, port int, use_ssl bool) (*PostgresClient, error)

func NewPostgresClientFromViper added in v0.31.0

func NewPostgresClientFromViper() (*PostgresClient, error)

func (*PostgresClient) CreateAssets added in v0.49.0

func (d *PostgresClient) CreateAssets(assets []models.Asset) ([]models.Asset, error)

func (*PostgresClient) CreateAttributes added in v0.49.0

func (d *PostgresClient) CreateAttributes(attributes []models.Attribute) ([]models.Attribute, error)

func (*PostgresClient) CreateEvent added in v0.49.0

func (d *PostgresClient) CreateEvent(content string) error

CreateEvent allows inserting into events when an asset or a tag is modified or deleted.

func (*PostgresClient) CreateTags added in v0.78.0

func (d *PostgresClient) CreateTags(tags []models.Tag) ([]models.Tag, error)

func (*PostgresClient) DeleteAsset added in v0.49.0

func (d *PostgresClient) DeleteAsset(asset_id int64) (models.Asset, []int64, error)

DeleteAsset deletes one asset identified by asset_id, returning the deleted asset as well as the ids of any asset that was affected by the deletion, and any error encountered.

func (*PostgresClient) DeleteAssetStatus added in v0.77.0

func (d *PostgresClient) DeleteAssetStatus(assetID int64) (resultAssetID int64, err error)

func (*PostgresClient) DeleteAssetTarget added in v0.77.0

func (d *PostgresClient) DeleteAssetTarget(assetID int64) (resultAssetID int64, err error)

func (*PostgresClient) DeleteAssets added in v0.50.0

func (d *PostgresClient) DeleteAssets(assetIDs []int64) ([]models.Asset, []int64, error)

DeleteAssets is a wrapper around DeleteAsset to loop over multiple assetIDs

TODO Move to sql-based logic for more efficiency

func (*PostgresClient) DeleteAttribute added in v0.57.0

func (d *PostgresClient) DeleteAttribute(attributeID int64) (deletedID int64, err error)

func (*PostgresClient) DeleteAttributes added in v0.57.0

func (d *PostgresClient) DeleteAttributes(attributeIDs []int64) (deletedIDs []int64, err error)

func (*PostgresClient) DeleteTag added in v0.78.0

func (d *PostgresClient) DeleteTag(tagID int64) (tag models.Tag, err error)

func (*PostgresClient) DeleteTags added in v0.78.0

func (d *PostgresClient) DeleteTags(tagIDs []int64) (ids []int64, err error)

DeleteTags attempts to restore the assets identified with assetIDs

It returns all modified asset's IDs and any error enountered.

func (*PostgresClient) GetAllAssets added in v0.49.0

func (d *PostgresClient) GetAllAssets(pageSize, page int) ([]models.Asset, error)

func (*PostgresClient) GetAsset added in v0.49.0

func (d *PostgresClient) GetAsset(id int64) (models.Asset, error)

func (*PostgresClient) GetAssetDescription added in v0.77.0

func (d *PostgresClient) GetAssetDescription(assetID int64) (resultAssetID int64, description string, err error)

func (*PostgresClient) GetAssetStatus added in v0.77.0

func (d *PostgresClient) GetAssetStatus(assetID int64) (resultAssetID int64, status string, err error)

func (*PostgresClient) GetAssetTarget added in v0.77.0

func (d *PostgresClient) GetAssetTarget(assetID int64) (resultAssetID int64, target int64, err error)

func (*PostgresClient) GetAssets added in v0.49.0

func (d *PostgresClient) GetAssets(deleted bool, pageSize, page int) ([]models.Asset, error)

func (*PostgresClient) GetAssetsDetailed added in v0.74.0

func (d *PostgresClient) GetAssetsDetailed(deleted bool, page, pageSize int) (assetsDetailed []models.AssetDetailed, err error)

GetAssetsDetailed returns a paginated amount of assets and their tags (asset-attributes)

TODO: Add tags value

func (*PostgresClient) GetAssetsWithAttribute added in v0.49.0

func (d *PostgresClient) GetAssetsWithAttribute(attributeID int64) ([]models.AssetWithAttributes, error)

GetAssetsWithAttribute returns all assets that have a specific attribute registered

func (*PostgresClient) GetAttribute added in v0.45.0

func (d *PostgresClient) GetAttribute(attributeID int64) (attribute models.Attribute, err error)

func (*PostgresClient) GetAttributeAllowEmptyValue added in v0.77.0

func (d *PostgresClient) GetAttributeAllowEmptyValue(attributeID int64) (allowEmptyValue bool, err error)

func (*PostgresClient) GetAttributes added in v0.49.0

func (d *PostgresClient) GetAttributes() (attributes []models.Attribute, err error)

func (*PostgresClient) GetAttributesAsKeyValuesForAsset added in v0.49.0

func (d *PostgresClient) GetAttributesAsKeyValuesForAsset(assetID int64) (keyValues []models.KeyValue, err error)

func (*PostgresClient) GetEvents added in v0.49.0

func (d *PostgresClient) GetEvents() (events []models.Event, err error)

func (*PostgresClient) GetTag added in v0.78.0

func (d *PostgresClient) GetTag(tagID int64) (tag models.Tag, err error)

func (*PostgresClient) GetTagAttribute added in v0.78.0

func (d *PostgresClient) GetTagAttribute(tagID int64) (attribute models.Attribute, err error)

func (*PostgresClient) GetTagDetailed added in v0.78.0

func (d *PostgresClient) GetTagDetailed(tagID int64) (tagDetailed models.TagDetailed, err error)

func (*PostgresClient) GetTagValue added in v0.78.0

func (d *PostgresClient) GetTagValue(tagID int64) (value string, err error)

func (*PostgresClient) GetTags added in v0.78.0

func (d *PostgresClient) GetTags() (tags []models.Tag, err error)

func (*PostgresClient) RestoreAsset added in v0.49.0

func (d *PostgresClient) RestoreAsset(asset_id int64) (models.Asset, error)

func (*PostgresClient) RestoreAssets added in v0.67.0

func (d *PostgresClient) RestoreAssets(assetIDs []int64) (ids []int64, err error)

RestoreAssets attempts to restore the assets identified with assetIDs

It returns all modified asset's IDs and any error enountered.

func (*PostgresClient) RestoreAttribute added in v0.57.0

func (d *PostgresClient) RestoreAttribute(attribute_id int64) (models.Attribute, error)

func (*PostgresClient) Seed added in v0.31.0

func (d *PostgresClient) Seed() (result sql.Result, err error)

Seed executes the schema defined in models.Scema.

It will add any tables that do not exist, but will not update the fields of existing ones.

func (*PostgresClient) UpdateAssetDescription added in v0.31.0

func (d *PostgresClient) UpdateAssetDescription(assetID int64, description string) (int64, string, error)

func (*PostgresClient) UpdateAssetStatus added in v0.31.0

func (d *PostgresClient) UpdateAssetStatus(assetID int64, status string) (resultAssetID int64, resultStatus string, err error)

func (*PostgresClient) UpdateAssetTarget added in v0.31.0

func (d *PostgresClient) UpdateAssetTarget(assetID, target int64) (int64, int64, error)

func (*PostgresClient) UpdateAttributeAllowEmptyValue added in v0.75.0

func (d *PostgresClient) UpdateAttributeAllowEmptyValue(attributeID int64, allowEmptyValue bool) (attribute models.Attribute, err error)

func (*PostgresClient) UpdateAttributeKey added in v0.75.0

func (d *PostgresClient) UpdateAttributeKey(attributeID int64, key string) (attribute models.Attribute, err error)

func (*PostgresClient) UpdateTagValue added in v0.78.0

func (d *PostgresClient) UpdateTagValue(tagID int64, value string) (models.Tag, error)

Jump to

Keyboard shortcuts

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