0

I created my database in "SCHEMA-Editor" from structr.org. I have two nodes "Project" and "ProjectManager" and relationship between these is "MEMBER". I made a cypher query to create the graph like this:

MATCH (a:Project),(b:ProjectManager)
WHERE a.name = 'X' AND b.name = 'Y'
CREATE (a)-[r:MEMBER]->(b)
RETURN r,a,b;

And i expected to display the graph, but i got this message: "MEMBER.id must_not_be_empty"

1 Answers1

3

Nodes and relationships created with Cypher are not immediately usable in Structr, because Cypher bypasses the Structr layer and acts directly on the database level. There are some extra steps that need to be done to make an object known to Structr: it needs an id attribute that contains a random UUID (universally unique identifier).

See "Tools" -> "Admin" -> "Relationships" -> "Add UUIDs" in the Schema Editor.

Additional tip: in Cypher, you should use MERGE instead of CREATE to avoid creating duplicate relationships between the two nodes (depending on your use-case).

  • Thanks. I have one more misunderstanding: For example a ProjectManager has many Projects and I want to display the graph with all the informations created in "Data-Field" also with relationship between nodes and for this i wrote this command: Match (n) return (n). Should I write a separately cypher code to create the relationship between the projects and the manager, it's not enough the schema? – Madalina Cristina May 30 '17 at 19:27
  • MATCH (m:Project { title: 'Proj' })<-[:MEMBER]-(ProjectManagers) RETURN ProjectManagers.name; I want to return all ProjectManagers that are Member in 'Proj'. – Madalina Cristina May 31 '17 at 05:16
  • 1
    All that can be done very easily in Structr, no need to use Cypher for simple queries like that. Please have a look at repeater elements (https://support.structr.com/article/275), StructrScript (https://support.structr.com/article/119) and especially the find() function (https://support.structr.com/article/53). – Christian Morgner Jun 01 '17 at 14:03
  • To answer your Cypher question: the query to return the project managers would be: MATCH (p:Project { title: 'Proj' })<-[MEMBER]-(m:ProjectManager) RETURN m – Christian Morgner Jun 01 '17 at 14:04
  • Thanks for the previous answer. – Madalina Cristina Jun 02 '17 at 10:49