Documentation
¶
Overview ¶
Package repository provides a database repository implementation for managing assets and relations. It allows creating, retrieving, and linking assets in the database.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Asset ¶
type Asset struct {
ID int64 `gorm:"primaryKey;autoIncrement:true"` // The unique identifier of the asset.
CreatedAt time.Time `gorm:"type:datetime"` // The creation timestamp of the asset.
Type string // The type of the asset.
Content datatypes.JSON // The JSON-encoded content of the asset.
}
Asset represents an asset stored in the database.
type Relation ¶
type Relation struct {
ID int64 `gorm:"primaryKey;autoIncrement:true"` // The unique identifier of the relation.
CreatedAt time.Time `gorm:"type:datetime"` // The creation timestamp of the relation.
Type string // The type of the relation.
FromAssetID int64 // The ID of the asset from which the relation originates.
ToAssetID int64 // The ID of the asset to which the relation points.
FromAsset Asset // The asset from which the relation originates.
ToAsset Asset // The asset to which the relation points.
}
Relation represents a relationship between two assets stored in the database.
type Repository ¶
type Repository interface {
CreateAsset(asset oam.Asset) (*types.Asset, error)
FindAssetById(id string) (*types.Asset, error)
FindAssetByContent(asset oam.Asset) ([]*types.Asset, error)
Link(source *types.Asset, relation string, destination *types.Asset) (*types.Relation, error)
IncomingRelations(asset *types.Asset, relationTypes ...string) ([]*types.Relation, error)
OutgoingRelations(asset *types.Asset, relationTypes ...string) ([]*types.Relation, error)
}
Repository defines the methods for interacting with the asset database. It provides operations for creating, retrieving, and linking assets.
Click to show internal directories.
Click to hide internal directories.