Skip to content

Commit

Permalink
added comments for create methods
Browse files Browse the repository at this point in the history
  • Loading branch information
caffix committed Nov 14, 2024
1 parent 7922355 commit 268916f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion repository/sqlrepo/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import (
"gorm.io/gorm"
)

// CreateEntityTag creates a new entity tag in the database.
// It takes an oam.Property as input and persists it in the database.
// The entity tag is serialized to JSON and stored in the Content field of the EntityTag struct.
// Returns the created entity tag as a types.EntityTag or an error if the creation fails.
func (sql *sqlRepository) CreateEntityTag(entity *types.Entity, prop oam.Property) (*types.EntityTag, error) {
jsonContent, err := prop.JSON()
if err != nil {
Expand Down Expand Up @@ -93,7 +97,7 @@ func (sql *sqlRepository) FindEntityTagById(id string) (*types.EntityTag, error)
}, nil
}

// GetEntityTags finds all tag for the entity with the specified names and last seen after the since parameter.
// GetEntityTags finds all tags for the entity with the specified names and last seen after the since parameter.
// If since.IsZero(), the parameter will be ignored.
// If no names are specified, all tags for the specified entity are returned.
func (sql *sqlRepository) GetEntityTags(entity *types.Entity, since time.Time, names ...string) ([]*types.EntityTag, error) {
Expand Down Expand Up @@ -163,6 +167,10 @@ func (sql *sqlRepository) DeleteEntityTag(id string) error {
return nil
}

// CreateEdgeTag creates a new edge tag in the database.
// It takes an oam.Property as input and persists it in the database.
// The edge tag is serialized to JSON and stored in the Content field of the EdgeTag struct.
// Returns the created edge tag as a types.EdgeTag or an error if the creation fails.
func (sql *sqlRepository) CreateEdgeTag(edge *types.Edge, prop oam.Property) (*types.EdgeTag, error) {
jsonContent, err := prop.JSON()
if err != nil {
Expand Down Expand Up @@ -243,6 +251,9 @@ func (sql *sqlRepository) FindEdgeTagById(id string) (*types.EdgeTag, error) {
}, nil
}

// GetEdgeTags finds all tags for the edge with the specified names and last seen after the since parameter.
// If since.IsZero(), the parameter will be ignored.
// If no names are specified, all tags for the specified edge are returned.
func (sql *sqlRepository) GetEdgeTags(edge *types.Edge, since time.Time, names ...string) ([]*types.EdgeTag, error) {
edgeId, err := strconv.ParseInt(edge.ID, 10, 64)
if err != nil {
Expand Down

0 comments on commit 268916f

Please sign in to comment.