moved neo4j integration

This commit is contained in:
David Janowski 2023-05-22 16:01:20 +02:00
parent 01fcb00191
commit 08502160cc
3 changed files with 0 additions and 66 deletions

View File

@ -1,15 +0,0 @@
package neo4j
import (
"fmt"
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
)
func NewConnection(uri string, username string, password string) (neo4j.DriverWithContext, error) {
driver, err := neo4j.NewDriverWithContext(uri, neo4j.BasicAuth(username, password, ""))
if err != nil {
return nil, fmt.Errorf("failed to create Neo4j driver: %v", err)
}
return driver, nil
}

View File

@ -1,24 +0,0 @@
package neo4j
import (
"context"
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
)
func CreateTagNode(ctx context.Context, driver neo4j.DriverWithContext, name string, tagType string) error {
query := `
MERGE (u:e621Tag {e621Tag: $name, e621TagType: $tagType})
RETURN u
`
params := map[string]interface{}{
"name": name,
"tagType": tagType,
}
_, err := neo4j.ExecuteQuery(ctx, driver, query, params, neo4j.EagerResultTransformer)
if err != nil {
return err
}
return nil
}

View File

@ -1,27 +0,0 @@
package neo4j
import (
"context"
"e621_to_neo4j/e621/api/models"
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
"log"
)
func CreateUserNode(ctx context.Context, driver neo4j.DriverWithContext, user models.E621User) error {
query := `
MERGE (u:e621User {e621ID: $id, e621Username: $name})
RETURN u
`
params := map[string]interface{}{
"id": user.ID,
"name": user.Name,
}
_, err := neo4j.ExecuteQuery(ctx, driver, query, params, neo4j.EagerResultTransformer)
if err != nil {
return err
}
log.Println("User node created successfully!")
return nil
}