OGMNeo
Abstract some trivial operations on the Neo4j driver for Nodejs and make the use simpler. That's why we created OGMNeo.
Installation
You can find ogmneo in npm here and install using the follow command
npm install ogmneo
Usage
Connecting to neo4j database
const ogmneo = ;ogmneoConnection;// Or if you want to add some neo4j driver configuration options ogmneoConnection;// See more about the config options you can add on: http://neo4j.com/docs/api/javascript-driver/current/function/index.html#static-function-driver
OGMNeo connects using the neo4j bolt protocol.
Log generated cypher on console
You can see the generated Cypher on your console by setting Connection.logCypherEnabled property true.
const ogmneo = ;ogmneoConnectionlogCypherEnabled = true;
Create node example
const ogmneo = ; ogmneoNode ;
Find Nodes
const ogmneo = ; let query = ogmneoQuery ; ogmneoNode ;
Create relations
You can create relations between nodes.
const ogmneo = ; ogmneoRelation ;
Find Relations
You can find the relation nodes.
const ogmneo = ; let query = ogmneoRelationQuery ; ogmneoRelation ; //OR ogmneoRelation ;
Executing Cypher
You can execute Cypher using the direct Neo4j Driver session object. Or you can use OGMNeoCypher.
const ogmneo = ; ogmneoCypher ; //OR ogmneoCypher ;
Creating and dropping indexes
You can create and drop indexes in properties.
const ogmneo = ; //Creating ogmneoIndex ; //Dropping ogmneoIndex ;
Operation API
Almost every method of ogmneo.Node and ogmneo.Relation have now the Operation API, that instead of executing the function on database returning a promise, it creates an ogmneo.Operation object that can be executed after by the ogmneo.OperationExecuter. Exemple:
const ogmneo = ; let operation = ogmneoNode; ogmneoOperationExecuter ;
Transactional API
With the Operation API we can now execute as many READ or WRITE operations on the same transaction. For example, you want to create nodes and then relate those two. But if the relationship operation fails you want to rollback all the operations.
const ogmneo = ; let createDriver = ogmneoNode; ogmneoOperationExecuter;
All of those operations will be executed on the same transaction and you can rollback anytime you want. The transaction is the neo4j driver transaction object and you can see more about it on their docs here.
Batching operation in a single transaction
You can also batch many operation READ or WRITE operations in a single transaction.
const ogmneo = ; let createUser1 = OGMNeoNode; let createUser2 = OGMNeoNode; ogmneoOperationExecuter;
If one of those fails, all other operations on the transaction will be rolledback automatically.
Documentation
See the full API documentation at docs. All docs was generated by JSDoc.
Exemple
See a demo sample on the ogmneo-demo repository.
Tests
Most of this library functions are covered by unit tests. See the code coverage on codecov.io.
Licence
OGMNeo is released under the MIT License.