╔═╗┬ ┬┌─┐┬ ┬┌─┐┬─┐ ╔╦╗┌─┐┌─┐┬ ┌─┐
║ └┬┘├─┘├─┤├┤ ├┬┘ ║ │ ││ ││ └─┐
╚═╝ ┴ ┴ ┴ ┴└─┘┴└─ ╩ └─┘└─┘┴─┘└─┘
(Ascii-art generated by patorjk.com)
Part of the Neo4J Line of Packages
isomorphic-node
^
|
+
isomorphic-cypher <--+ template-query-object
^ ^
| |
| +
| + neo4j-query-object
+ |
simple-neo4j <------+ neo4j-parser
|
+ cypher-tools
ascii-chart generated by asciiflow.com
About
Cypher tools makes working with Cypher a bit more fun, currently its still in its early stages but aims to be a general toolset for cypher queries.
Using Cypher Tools
-
Object to String (objToString)
Converts an object to something like JSON but in a way that's readable by and includable in a cypher query. Great for times when Cypher parameters can't be used and you must resort to string building
objToString({ movie: "The One", genre: "Action" }) // Returns // '{ movie: "The One", genre: "Action" }'
-
Object to Parameters (objToParams)
Converts an object to something like JSON, very similar to above, but the resulting string doesn't provide the values in the values field like above. It instead tells Neo4J to look for the values in a provided parameter. In other words, a loopback object string.
This is needed in situations where an object parameter can be used but the parameter can't be used directly, only the parameter contents.
A good example is the predicate in a match or merge statement, you can't do this
match ({predicate})
but you can do thismatch ({key: {predicate}.key})
. That's essentially what this method does.objToParams("predicate", { movie: "The One", genre: "Action" })
// Returns // '{ movie: {predicate}.movie, genre: {predicate}.genre }'
Note: Always use parameters wherever possible, for a number of reasons, among them is faster code, speed, and many automated optimizations on the database side.
-
Labels to String (labelsToString)
Converts an array of labels to a string, a simple and quick helper function but very useful.
labelsToString(["Movie", "Action"]) // Returns // ":Movie:Action"
This package is solid
This package is actively tested with Jasmine and thoroughly documented throughout. It also contains complete JSDoc comments and full online JSDoc generated documentation.
Do you like this package or have an issue?
If this package has helped you I encourage you to follow it, give it a star, or fork it on github. If you have any ideas, suggestions, issues, or ways to improve upon it then let us know over at github by filing an issue.
Contributions are also encouraged and the CONTRIBUTING.md file shows all the details on development and how to contribute back but its mostly just commit changes and send a pull request.
This project is licensed Apache 2.0
http://www.apache.org/licenses/LICENSE-2.0.txt
Run it in your browser
Thanks to TonicDev, you now have a way to run this package right in your browser to test it out. If your on the NPM site you can see the TonicDev link on the right-hand side, otherwise you can always go to the link below.
TonicDev will load up a preset example we provide that you can play around with to get a feel for this package.
https://tonicdev.com/npm/cypher-tools
How to develop
To develop, git clone
this repository and npm install
to install the
development dependencies. Make sure to run npm run build
when
needed which will test & compile ES6/7 to ES5 and re-generate the docs.
You can run those individually if you want with npm run docs
and
npm run compile
. To auto-copy over docs from master to gh-pages run
npm run pages
before committing and pushing.
For testing, just run npm run test
If you want to contribute back read the CONTRIBUTING.md
file.
Documentation
Detailed documentation exists for this package, it should already by viewable on clone. Feel free to look through it for any questions you may have. The source code is also heavily documented if you want to look through it as well for answers.
Online docs exist here http://junestoolbox.github.io/cypher-tools/docs/
Whats New
Check out the CHANGELOG.md file for latest changes and updates