Documentation ¶
Overview ¶
Package db provides mechanisms for interacting with a database directly
Index ¶
- type PostgresClient
- func (d *PostgresClient) CreateAssetAttributes(assetAttributes []models.AssetAttribute) ([]models.AssetAttribute, error)
- func (d *PostgresClient) CreateAssets(assets []models.Asset) ([]models.Asset, error)
- func (d *PostgresClient) CreateAttributes(attributes []models.Attribute) ([]models.Attribute, error)
- func (d *PostgresClient) CreateEvent(content string) error
- func (d *PostgresClient) DeleteAsset(asset_id int64) (models.Asset, []int64, error)
- func (d *PostgresClient) DeleteAssetAttribute(assetAttributeID int64) (assetAttribute models.AssetAttribute, err error)
- func (d *PostgresClient) DeleteAssets(assetIDs []int64) ([]models.Asset, []int64, error)
- func (d *PostgresClient) DeleteAttribute(attributeID int64) (models.Attribute, error)
- func (d *PostgresClient) DeleteAttributes(attributeIDs []int64) ([]models.Attribute, error)
- func (d *PostgresClient) GetAllAssets(pageSize, page int) ([]models.Asset, error)
- func (d *PostgresClient) GetAsset(id int64) (models.Asset, error)
- func (d *PostgresClient) GetAssetAttribute(assetAttributeID int64) (assetAttribute models.AssetAttribute, err error)
- func (d *PostgresClient) GetAssetAttributes() (assetAttributes []models.AssetAttribute, err error)
- func (d *PostgresClient) GetAssets(deleted bool, pageSize, page int) ([]models.Asset, error)
- func (d *PostgresClient) GetAssetsWithAttribute(attributeID int64) ([]models.AssetWithAttributes, error)
- func (d *PostgresClient) GetAttribute(attributeID int64) (attribute models.Attribute, err error)
- func (d *PostgresClient) GetAttributes() (attributes []models.Attribute, err error)
- func (d *PostgresClient) GetAttributesAsKeyValuesForAsset(assetID int64) (keyValues []models.KeyValue, err error)
- func (d *PostgresClient) GetEvents() (events []models.Event, err error)
- func (d *PostgresClient) RestoreAsset(asset_id int64) (models.Asset, error)
- func (d *PostgresClient) RestoreAttribute(attribute_id int64) (models.Attribute, error)
- func (d *PostgresClient) Seed() (sql.Result, error)
- func (d *PostgresClient) UpdateAssetAttributeValue(assetAttributeID int64, value string) (models.AssetAttribute, error)
- func (d *PostgresClient) UpdateAssetDescription(assetID int64, description string) (int64, string, error)
- func (d *PostgresClient) UpdateAssetStatus(assetID int64, status string) (int64, string, error)
- func (d *PostgresClient) UpdateAssetTarget(assetID, target int64) (int64, int64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PostgresClient ¶ added in v0.31.0
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) CreateAssetAttributes ¶ added in v0.49.0
func (d *PostgresClient) CreateAssetAttributes(assetAttributes []models.AssetAttribute) ([]models.AssetAttribute, error)
func (*PostgresClient) CreateAssets ¶ added in v0.49.0
func (*PostgresClient) CreateAttributes ¶ added in v0.49.0
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) DeleteAsset ¶ added in v0.49.0
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) DeleteAssetAttribute ¶ added in v0.52.0
func (d *PostgresClient) DeleteAssetAttribute(assetAttributeID int64) (assetAttribute models.AssetAttribute, err error)
func (*PostgresClient) DeleteAssets ¶ added in v0.50.0
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) (models.Attribute, error)
func (*PostgresClient) DeleteAttributes ¶ added in v0.57.0
func (d *PostgresClient) DeleteAttributes(attributeIDs []int64) ([]models.Attribute, error)
DeleteAttributes is a wrapper around DeleteAttribute to loop over multiple assetIDs
TODO Move to sql-based logic for more efficiency
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) GetAssetAttribute ¶ added in v0.64.0
func (d *PostgresClient) GetAssetAttribute(assetAttributeID int64) (assetAttribute models.AssetAttribute, err error)
func (*PostgresClient) GetAssetAttributes ¶ added in v0.49.0
func (d *PostgresClient) GetAssetAttributes() (assetAttributes []models.AssetAttribute, err error)
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) 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) RestoreAsset ¶ added in v0.49.0
func (d *PostgresClient) RestoreAsset(asset_id int64) (models.Asset, error)
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() (sql.Result, 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) UpdateAssetAttributeValue ¶ added in v0.65.0
func (d *PostgresClient) UpdateAssetAttributeValue(assetAttributeID int64, value string) (models.AssetAttribute, error)
func (*PostgresClient) UpdateAssetDescription ¶ added in v0.31.0
func (*PostgresClient) UpdateAssetStatus ¶ added in v0.31.0
func (*PostgresClient) UpdateAssetTarget ¶ added in v0.31.0
func (d *PostgresClient) UpdateAssetTarget(assetID, target int64) (int64, int64, error)