Neo4j: Basic Example Using Groovy’s Sugar
Neo4j is basically a Java library with Java API, so it can always benefit from a bit of Groovy sugar.
Note: in case the embed doesn’t work, the original code can be found ☞ here
The “sugar” part is the metaClass code.
Node.metaClass {
propertyMissing { String name, val -> delegate.setProperty(name, val) }
propertyMissing { String name -> delegate.getProperty(name) }
methodMissing { String name, args ->
delegate.createRelationshipTo(args[0], MyRelationshipTypes."$name")
}
}
Relationship.metaClass {
propertyMissing { String name, val -> delegate.setProperty(name, val) }
propertyMissing { String name -> delegate.getProperty(name) }
}
Original title and link: Neo4j: Basic Example Using Groovy’s Sugar (NoSQL databases © myNoSQL)