mirror of
https://github.com/vcscsvcscs/GenerationsHeritage.git
synced 2025-08-13 22:39:06 +02:00
embed queries (in progress)
This commit is contained in:
60
apps/db-adapter/pkg/memgraph/queries.go
Normal file
60
apps/db-adapter/pkg/memgraph/queries.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package memgraph
|
||||
|
||||
import _ "embed"
|
||||
|
||||
//go:embed queries/create_indexes.cypher
|
||||
var CreateIndexesCypherQuery string
|
||||
|
||||
//go:embed queries/drop_indexes.cypher
|
||||
var DropIndexesCypherQuery string
|
||||
|
||||
//go:embed queries/create_constraints.cypher
|
||||
var CreateConstraintsCypherQuery string
|
||||
|
||||
//go:embed queries/drop_constraints.cypher
|
||||
var DropConstraintsCypherQuery string
|
||||
|
||||
// Requires Person parameter.
|
||||
// Returns p as person
|
||||
//go:embed queries/create_person.cypher
|
||||
var CreatePersonCypherQuery string
|
||||
|
||||
// Requires id parameter.
|
||||
// Returns n as person
|
||||
//go:embed queries/get_person_by_id.cypher
|
||||
var GetPersonCypherQuery string
|
||||
|
||||
// Requires id, props parameter.
|
||||
// Returns n as person
|
||||
//go:embed queries/update_person.cypher
|
||||
var UpdatePersonCypherQuery string
|
||||
|
||||
// Requires google_id parameter.
|
||||
// Returns n as person
|
||||
//go:embed queries/get_person_by_google_id.cypher
|
||||
var GetPersonByGoogleIdCypherQuery string
|
||||
|
||||
// Requires id parameter.
|
||||
// Returns labels(n) AS labels, n AS person
|
||||
//go:embed queries/soft_delete_person_by_id.cypher
|
||||
var SoftDeletePersonCypherQuery string
|
||||
|
||||
// Requires id parameter.
|
||||
//go:embed queries/hard_delete_person_by_id.cypher
|
||||
var HardDeletePersonCypherQuery string
|
||||
|
||||
// Requires id1, id2 parameters.
|
||||
//go:embed queries/get_relationship.cypher
|
||||
var GetRelationshipCypherQuery string
|
||||
|
||||
// Requires id1, id2, Relationship parameters.
|
||||
//go:embed queries/create_directed_relationship.cypher
|
||||
var CreateDirectedRelationshipCypherQuery string
|
||||
|
||||
// Requires id1, id2, Relationship1, Relationship2 parameters.
|
||||
//go:embed queries/create_two_directed_relationships.cypher
|
||||
var CreateTwoDirectedRelationshipCypherQuery string
|
||||
|
||||
// Requires id parameter.
|
||||
//go:embed queries/get_family_tree_by_id.cypher
|
||||
var GetFamilyTreeByIdCypherQuery string
|
@@ -5,10 +5,3 @@ CREATE CONSTRAINT ON (n:Person) ASSERT EXISTS (n.mothers_first_name);
|
||||
CREATE CONSTRAINT ON (n:Person) ASSERT EXISTS (n.mothers_last_name);
|
||||
CREATE CONSTRAINT ON (n:Person) ASSERT n.google_id IS UNIQUE;
|
||||
CREATE CONSTRAINT ON (n:Person) ASSERT n.last_name, n.first_name, n.born, n.mothers_first_name, n.mothers_last_name IS UNIQUE;
|
||||
|
||||
CREATE INDEX ON :Person(google_id);
|
||||
CREATE INDEX ON :Person(last_name);
|
||||
CREATE INDEX ON :Person(first_name);
|
||||
CREATE INDEX ON :Person(born);
|
||||
CREATE INDEX ON :Person(mothers_first_name);
|
||||
CREATE INDEX ON :Person(mothers_last_name);
|
@@ -1,4 +1,5 @@
|
||||
MATCH (a:Person), (b:Person)
|
||||
MATCH (a:Person)
|
||||
OPTIONAL MATCH (b:Person)
|
||||
WHERE id(a) = $id1 AND id(b) = $id2
|
||||
CREATE (a)-[r:Relationship $Relationship]->(b)
|
||||
RETURN r AS relationship
|
||||
RETURN r AS relationship;
|
@@ -0,0 +1,6 @@
|
||||
CREATE INDEX ON :Person(google_id);
|
||||
CREATE INDEX ON :Person(last_name);
|
||||
CREATE INDEX ON :Person(first_name);
|
||||
CREATE INDEX ON :Person(born);
|
||||
CREATE INDEX ON :Person(mothers_first_name);
|
||||
CREATE INDEX ON :Person(mothers_last_name);
|
@@ -0,0 +1,7 @@
|
||||
DROP CONSTRAINT ON (n:Person) ASSERT EXISTS (n.last_name);
|
||||
DROP CONSTRAINT ON (n:Person) ASSERT EXISTS (n.first_name);
|
||||
DROP CONSTRAINT ON (n:Person) ASSERT EXISTS (n.born);
|
||||
DROP CONSTRAINT ON (n:Person) ASSERT EXISTS (n.mothers_first_name);
|
||||
DROP CONSTRAINT ON (n:Person) ASSERT EXISTS (n.mothers_last_name);
|
||||
DROP CONSTRAINT ON (n:Person) ASSERT n.google_id IS UNIQUE;
|
||||
DROP CONSTRAINT ON (n:Person) ASSERT n.last_name, n.first_name, n.born, n.mothers_first_name, n.mothers_last_name IS UNIQUE;
|
6
apps/db-adapter/pkg/memgraph/queries/drop_indexes.cypher
Normal file
6
apps/db-adapter/pkg/memgraph/queries/drop_indexes.cypher
Normal file
@@ -0,0 +1,6 @@
|
||||
DROP INDEX ON :Person(google_id);
|
||||
DROP INDEX ON :Person(last_name);
|
||||
DROP INDEX ON :Person(first_name);
|
||||
DROP INDEX ON :Person(born);
|
||||
DROP INDEX ON :Person(mothers_first_name);
|
||||
DROP INDEX ON :Person(mothers_last_name);
|
@@ -0,0 +1,4 @@
|
||||
MATCH (n:Person)-[p:Parent*1..]->(family:Person)
|
||||
WHERE id(n) = $id
|
||||
OPTIONAL MATCH (family)-[c:Child*1..]->(children:Person)
|
||||
RETURN family, p, children, c, n
|
@@ -1,6 +1,6 @@
|
||||
MATCH (n:Person)-[p:Parent*1..]->(family:Person)
|
||||
WHERE id(n) = $id
|
||||
OPTIONAL MATCH (family)-[c:Child]->(children:Person)
|
||||
OPTIONAL MATCH (family)-[c:Child*..4]->(children:Person)
|
||||
WITH family, p, children, c, n
|
||||
OPTIONAL MATCH (children)<-[p2:Parent]-(OtherParents:Person)
|
||||
WITH family, p, children, c, OtherParents, p2, n
|
||||
|
@@ -0,0 +1,4 @@
|
||||
MATCH (n:Person)-[p:Parent*1..]->(family:Person)
|
||||
WHERE id(n) = $id
|
||||
OPTIONAL MATCH (family)-[c:Child*..4]->(children:Person)
|
||||
RETURN family, p, children, c, n
|
@@ -1 +0,0 @@
|
||||
MATCH (n:Person) WHERE n.id = $id RETURN n AS people
|
Reference in New Issue
Block a user