package neo4jAPI import ( "context" "github.com/neo4j/neo4j-go-driver/v5/neo4j" ) func PostToTagRelationship(ctx context.Context, driver neo4j.DriverWithContext, e621PostID int64, e621Tag string) error { query := ` MATCH (p:e621Post {e621PostID: $e621PostID}) MATCH (t:e621Tag {e621Tag: $e621Tag}) MERGE (p)-[:HAS_TAG]->(t) ` params := map[string]interface{}{ "e621PostID": e621PostID, "e621Tag": e621Tag, } _, err := neo4j.ExecuteQuery(ctx, driver, query, params, neo4j.EagerResultTransformer) if err != nil { return err } return nil } func PostToSourceRelationship(ctx context.Context, driver neo4j.DriverWithContext, e621PostID int64, sourceURL string) error { query := ` MATCH (p:e621Post {e621PostID: $e621PostID}) MATCH (s:Source {URL: $sourceURL}) MERGE (p)-[:HAS_SOURCE]->(s) ` params := map[string]interface{}{ "e621PostID": e621PostID, "sourceURL": sourceURL, } _, err := neo4j.ExecuteQuery(ctx, driver, query, params, neo4j.EagerResultTransformer) if err != nil { return err } return nil } func UserToPostRelationship(ctx context.Context, driver neo4j.DriverWithContext, e621PostID int64, e621UserID int64) error { query := ` MATCH (p:e621Post {e621PostID: $e621PostID}) MATCH (u:e621User {e621ID: $e621ID}) MERGE (u)-[:IS_FAVORITE]->(p) ` params := map[string]interface{}{ "e621PostID": e621PostID, "e621ID": e621UserID, } _, err := neo4j.ExecuteQuery(ctx, driver, query, params, neo4j.EagerResultTransformer) if err != nil { return err } return nil }