Cypher Builder - Beta
The Cypher builder is a library for building Cypher for Neo4j queries with a programmatic API.
Note that this library is still under development.
Try it live on CodePen.
Getting Started
import Cypher from "@neo4j/cypher-builder";
const movieNode = new Cypher.Node({
labels: ["Movie"],
});
const matchQuery = new Cypher.Match(movieNode)
.where(movieNode, {
title: new Cypher.Param("The Matrix"),
})
.return(movieNode.property("title"));
const { cypher, params } = matchQuery.build();
console.log(cypher);
console.log(params);
In this example, cypher
will be a string containing the following:
MATCH (this0:`Movie`)
WHERE this0.title = $param0
RETURN this0.title
params
will contain the parameters used in that query as an object:
{
"param0": "The Matrix",
}
Examples
You can find usage examples in the examples folder and in CodePen.
Development
npm test
to run cypher builder testsnpm run build
to compile cypher builder librarynpm run docs
to generate the API reference docs