I tried to update the grails_neo4j and micronaut_neo4j, but without success. Grails and my Micronaut app use GORM to abstract away from the database, and the Neo4j plugins are waiting on some Groovy upgrades. So for now, these two apps are DOA.

I moved from a locally installed Neo4j to one that runs in a Docker container. I took this opportunity to experiment with Cypher (cheatsheet) to create the Seed Data dataset.

  • Raw Cypher queries, with embedded data.
  • JSON payloads for the HTTP API, with data passed in parameters.
  • Use Cypher Shell to run queries with parameters.

I haven’t found an easy way to extract the id assigned to nodes as the database creates them to create relationships. But the syntax allows chaining multiple parts in the CREATE of a query, and reuse references between these parts.

match
  (reviewer:User {email: "jean@jeantessier.com"})
create
  (b:Book {name: "The\_Fellowship\_of\_the\_Ring", authors: ["J.R.R. Tolkien"], publisher: "Unwin & Allen", years: [1954]}),
  (b)-[:TITLE]->(:Title {title: "The Fellowship of the Ring", link: "https://en.wikipedia.org/wiki/The\_Fellowship\_of\_the\_Ring"}),
  (b)<-[:BOOK]-(:Review {body: "The Council of Elrond is a little long.", start: "2020-05-02", stop: "2020-05-05"})-[:REVIEWER]->(reviewer)
return b
;

The first part creates a Book node and saves it as b. The second part creates a Title node and a TITLE relationship from b to this new node. The third part creates a Review node and relates it to b and a reviewer node.

This makes for a very compact invocation, but it is less reusable when books have different numbers of titles and/or reviews.