rm unused funcs

This commit is contained in:
2025-04-01 20:46:23 +02:00
parent d3e4202e06
commit 47c5d868d0
5 changed files with 0 additions and 189 deletions

View File

@@ -1,30 +0,0 @@
package memgraph
import (
"fmt"
"time"
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
"golang.org/x/net/context"
)
func (p *Person) CreatePerson(driver neo4j.DriverWithContext) (*neo4j.Record, error) {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
session := driver.NewSession(ctx, neo4j.SessionConfig{AccessMode: neo4j.AccessModeWrite})
defer session.Close(ctx)
if err := p.Verify(); err != nil {
return nil, err
}
query := fmt.Sprintf("CREATE (n:Person {%s}) RETURN n;", p.ToString())
result, err := session.Run(ctx, query, nil)
if err != nil {
return nil, err
}
return result.Single(ctx)
}

View File

@@ -1,39 +0,0 @@
package memgraph
import (
"fmt"
"time"
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
"golang.org/x/net/context"
)
func (r *Relationship) CreateRelationship(driver neo4j.DriverWithContext) (*neo4j.Record, error) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
session := driver.NewSession(ctx, neo4j.SessionConfig{AccessMode: neo4j.AccessModeWrite})
defer session.Close(ctx)
if err := r.Verify(); err != nil {
return nil, err
}
query := fmt.Sprintf(`MATCH (a:Person), (b:Person) WHERE a.id = '%s' AND b.id = '%s'`, r.FirstPersonID, r.SecondPersonID)
if r.Direction == "->" {
query = fmt.Sprintf(`%s CREATE (a)-[r:%s {verified: false}]->(b) RETURN r;`, query, r.Relationship)
} else if r.Direction == "<-" {
query = fmt.Sprintf(`%s CREATE (a)<-[r:%s {verified: false}]-(b) RETURN r;`, query, r.Relationship)
} else {
query = fmt.Sprintf(`%s CREATE (a)<-[r1:%s {verified: True}]-(b) CREATE (a)-[r2:%s {verified: True}]->(b) RETURN r1, r2;`,
query, r.Relationship, r.Relationship)
}
result, err := session.Run(ctx, query, nil)
if err != nil {
return nil, err
}
return result.Single(ctx)
}

View File

@@ -1,45 +0,0 @@
package memgraph
import (
"fmt"
"strings"
"time"
"github.com/google/uuid"
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
"golang.org/x/net/context"
)
func (rp *RelationshipAndPerson) CreateRelationshipAndPerson(driver neo4j.DriverWithContext) (*neo4j.Record, error) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
session := driver.NewSession(ctx, neo4j.SessionConfig{AccessMode: neo4j.AccessModeWrite})
defer session.Close(ctx)
if err := rp.Verify(); err != nil {
return nil, err
}
rp.Person.ID = strings.ReplaceAll(uuid.New().String(), "-", "")
query := fmt.Sprintf(`MATCH (a:Person) WHERE a.id = '%s'`, rp.Relationship.FirstPersonID)
query = fmt.Sprintf("%s CREATE (b:Person {%s})", query, rp.Person.ToString())
if rp.Relationship.Direction == "->" {
query = fmt.Sprintf(`%s CREATE (a)-[r:%s {verified: True}]->(b) RETURN r;`, query, rp.Relationship.Relationship)
} else if rp.Relationship.Direction == "<-" {
query = fmt.Sprintf(`%s CREATE (a)<-[r:%s {verified: True}]-(b) RETURN r;`, query, rp.Relationship.Relationship)
} else {
query = fmt.Sprintf(`%s CREATE (a)<-[r1:%s {verified: True}]-(b) CREATE (a)-[r2:%s {verified: True}]->(b) RETURN r1, r2, b;`,
query, rp.Relationship.Relationship, rp.Relationship.Relationship)
}
result, err := session.Run(ctx, query, nil)
if err != nil {
return nil, err
}
return result.Single(ctx)
}

View File

@@ -1,36 +0,0 @@
package memgraph
import (
"fmt"
"time"
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
"golang.org/x/net/context"
)
func (r *Relationship) DeleteRelationship(driver neo4j.DriverWithContext) error {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
session := driver.NewSession(ctx, neo4j.SessionConfig{AccessMode: neo4j.AccessModeWrite})
defer session.Close(ctx)
if err := r.Verify(); err != nil {
return err
}
query := ""
if r.Direction == "->" {
query = fmt.Sprintf(`MATCH (a)-[r:%s]->(b)`, r.Relationship)
} else if r.Direction == "<-" {
query = fmt.Sprintf(`MATCH (a)<-[r:%s]-(b)`, r.Relationship)
} else {
query = fmt.Sprintf(`MATCH (a)-[r:%s]-(b)`, r.Relationship)
}
query = fmt.Sprintf(`%s WHERE a.id = '%s' AND b.id = '%s' DELETE r;`, query, r.FirstPersonID, r.SecondPersonID)
_, err := session.Run(ctx, query, nil)
return err
}

View File

@@ -1,39 +0,0 @@
package memgraph
import (
"fmt"
"time"
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
"golang.org/x/net/context"
)
func (r *Relationship) VerifyRelationship(driver neo4j.DriverWithContext) (*neo4j.Record, error) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
session := driver.NewSession(ctx, neo4j.SessionConfig{AccessMode: neo4j.AccessModeWrite})
defer session.Close(ctx)
if err := r.Verify(); err != nil {
return nil, err
}
query := ""
if r.Direction == "->" {
query = fmt.Sprintf(`MATCH (a)-[r:%s]->(b)`, r.Relationship)
} else if r.Direction == "<-" {
query = fmt.Sprintf(`MATCH (a)<-[r:%s]-(b)`, r.Relationship)
} else {
query = fmt.Sprintf(`MATCH (a)-[r:%s]-(b)`, r.Relationship)
}
query = fmt.Sprintf(`%s WHERE a.id = %s AND b.id = %s set r.verified = true return r;`, query, r.FirstPersonID, r.SecondPersonID)
result, err := session.Run(ctx, query, nil)
if err != nil {
return nil, err
}
return result.Single(ctx)
}