33 lines
832 B
Go
33 lines
832 B
Go
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
|
|
}
|