feat: added post node creation

This commit is contained in:
SoXX 2024-02-16 16:05:05 +01:00
parent 5ebb855c63
commit f34f53f24a
2 changed files with 32 additions and 2 deletions

View File

@ -1 +1,32 @@
package internal package internal
import (
"context"
"git.dragse.it/anthrove/anthrove-graph-sdk.git/pkg/models"
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
log "github.com/sirupsen/logrus"
)
func CreateAnthrovePostNode(ctx context.Context, driver neo4j.DriverWithContext, anthrovePost *models.AnthrovePost) error {
query := `
CREATE (newPostNode:AnthrovePost {post_id: $anthrove_post_id, rating: $anthrove_rating})
`
params := map[string]any{
"anthrove_post_id": anthrovePost.PostID,
"anthrove_rating": anthrovePost.Rating,
}
_, err := neo4j.ExecuteQuery(ctx, driver, query, params, neo4j.EagerResultTransformer)
if err != nil {
return err
}
log.WithFields(log.Fields{
"anthrove_post_id": anthrovePost.PostID,
"anthrove_post_rating": anthrovePost.Rating,
}).Trace("graph: created anthrove post")
return nil
}

View File

@ -45,8 +45,7 @@ func (g *graphConnection) AddSourceToGraph(ctx context.Context, anthroveSource *
} }
func (g *graphConnection) AddPostToGraph(ctx context.Context, anthrovePost *models.AnthrovePost) error { func (g *graphConnection) AddPostToGraph(ctx context.Context, anthrovePost *models.AnthrovePost) error {
//TODO implement me return internal.CreateAnthrovePostNode(ctx, g.driver, anthrovePost)
panic("implement me")
} }
func (g *graphConnection) AddTagToGraph(ctx context.Context, anthrovePost *models.AnthrovePost, anthroveTag *models.AnthroveTag) error { func (g *graphConnection) AddTagToGraph(ctx context.Context, anthrovePost *models.AnthrovePost, anthroveTag *models.AnthroveTag) error {