assetdb

package module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: Apache-2.0 Imports: 4 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssetDB added in v0.1.1

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

AssetDB represents the asset database service.

func New

func New(dbType repository.DBType, dsn string) *AssetDB

New creates a new assetDB instance. It initializes the asset database with the specified database type and DSN.

func (*AssetDB) AssetQuery added in v0.3.6

func (as *AssetDB) AssetQuery(constraints string) ([]*types.Asset, error)

AssetQuery executes a query against the asset table of the db. For SQL databases, the query will start with "SELECT * FROM assets " and then add the necessary constraints.

func (*AssetDB) Close added in v0.4.1

func (as *AssetDB) Close() error

Close will close the assetdb and return any errors.

func (*AssetDB) Create added in v0.1.1

func (as *AssetDB) Create(source *types.Asset, relation string, discovered oam.Asset) (*types.Asset, error)

Create creates a new asset in the database. If source is nil, the discovered asset will be created and relation will be ignored If source and relation are provided, the asset is created and linked to the source asset using the specified relation. It returns the newly created asset and an error, if any.

func (*AssetDB) DeleteAsset added in v0.2.0

func (as *AssetDB) DeleteAsset(id string) error

DeleteAsset removes an asset in the database by its ID.

func (*AssetDB) DeleteRelation added in v0.2.0

func (as *AssetDB) DeleteRelation(id string) error

DeleteRelation removes a relation in the database by its ID.

func (*AssetDB) FindByContent added in v0.1.1

func (as *AssetDB) FindByContent(asset oam.Asset, since time.Time) ([]*types.Asset, error)

FindByContent finds assets in the database based on their content and last seen after the since parameter. If since.IsZero(), the parameter will be ignored. It returns a list of matching assets and an error, if any.

func (*AssetDB) FindById added in v0.1.1

func (as *AssetDB) FindById(id string, since time.Time) (*types.Asset, error)

FindById finds an asset in the database by its ID and last seen after the since parameter. If since.IsZero(), the parameter will be ignored. It returns the matching asset and an error, if any.

func (*AssetDB) FindByScope added in v0.2.0

func (as *AssetDB) FindByScope(constraints []oam.Asset, since time.Time) ([]*types.Asset, error)

FindByScope finds assets in the database by applying all the scope constraints provided and last seen after the since parameter. If since.IsZero(), the parameter will be ignored. It returns the matching assets and an error, if any.

func (*AssetDB) FindByType added in v0.2.0

func (as *AssetDB) FindByType(atype oam.AssetType, since time.Time) ([]*types.Asset, error)

FindByType finds all assets in the database of the provided asset type and last seen after the since parameter. If since.IsZero(), the parameter will be ignored. It returns the matching assets and an error, if any.

func (*AssetDB) GetDBType added in v0.3.6

func (as *AssetDB) GetDBType() string

GetDBType returns the type of the underlying database.

func (*AssetDB) IncomingRelations added in v0.1.1

func (as *AssetDB) IncomingRelations(asset *types.Asset, since time.Time, relationTypes ...string) ([]*types.Relation, error)

IncomingRelations finds all relations pointing to `asset“ for the specified `relationTypes`, if any. If since.IsZero(), the parameter will be ignored. If no `relationTypes` are specified, all incoming relations are returned.

func (as *AssetDB) Link(source *types.Asset, relation string, destination *types.Asset) (*types.Relation, error)

Link creates a relation between two assets in the database. It takes the source asset, relation type, and destination asset as inputs. The relation is established by creating a new Relation in the database, linking the two assets. Returns the created relation as a types.Relation or an error if the link creation fails.

func (*AssetDB) OutgoingRelations added in v0.1.1

func (as *AssetDB) OutgoingRelations(asset *types.Asset, since time.Time, relationTypes ...string) ([]*types.Relation, error)

OutgoingRelations finds all relations from `asset“ to another asset for the specified `relationTypes`, if any. If since.IsZero(), the parameter will be ignored. If no `relationTypes` are specified, all outgoing relations are returned.

func (*AssetDB) RawQuery added in v0.3.6

func (as *AssetDB) RawQuery(sqlstr string, results interface{}) error

RawQuery executes a query defined by the provided sqlstr on the asset-db. The results of the executed query are scanned into the provided slice.

func (*AssetDB) RelationQuery added in v0.3.6

func (as *AssetDB) RelationQuery(constraints string) ([]*types.Relation, error)

RelationQuery executes a query against the relation table of the db. For SQL databases, the query will start with "SELECT * FROM relations " and then add the necessary constraints.

func (*AssetDB) UpdateAssetLastSeen added in v0.5.1

func (as *AssetDB) UpdateAssetLastSeen(id string) error

UpdateAssetLastSeen updates the asset last seen field to the current time by its ID.

Directories

Path Synopsis
migrations
postgres
Integrates with migration tools recognizing the standard "migrate up" and "migrate down" annotations, simplifying asset database schema management and rollbacks in Postgres.
Integrates with migration tools recognizing the standard "migrate up" and "migrate down" annotations, simplifying asset database schema management and rollbacks in Postgres.
sqlite3
Integrates with migration tools recognizing the standard "migrate up" and "migrate down" annotations, simplifying asset database schema management and rollbacks in SQLite3.
Integrates with migration tools recognizing the standard "migrate up" and "migrate down" annotations, simplifying asset database schema management and rollbacks in SQLite3.
Package types provides types that represent models in databases but are not tied to a specific database implementation.
Package types provides types that represent models in databases but are not tied to a specific database implementation.

Jump to

Keyboard shortcuts

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