All Projects → LucianoPAlmeida → OGMNeo

LucianoPAlmeida / OGMNeo

Licence: MIT license
[No Maintenance] Neo4j nodeJS OGM(object-graph mapping) abstraction layer

Programming Languages

javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to OGMNeo

neo4rs
Neo4j driver for rust
Stars: ✭ 41 (-24.07%)
Mutual labels:  neo4j, neo4j-driver, bolt, cypher
NeoClient
🦉 Lightweight OGM for Neo4j which support transactions and BOLT protocol.
Stars: ✭ 21 (-61.11%)
Mutual labels:  neo4j, bolt, cypher, ogm-neo4j
neo4j-java-driver-spring-boot-starter
Automatic configuration of Neo4j's Java Driver for Spring Boot applications
Stars: ✭ 33 (-38.89%)
Mutual labels:  neo4j, neo4j-driver, bolt
neo4j-php-client
Php client and driver for neo4j database
Stars: ✭ 95 (+75.93%)
Mutual labels:  neo4j, transaction, bolt
seabolt
Neo4j Bolt Connector for C
Stars: ✭ 37 (-31.48%)
Mutual labels:  neo4j, neo4j-driver, cypher
angular-neo4j
Neo4j Bolt driver wrapper for Angular
Stars: ✭ 18 (-66.67%)
Mutual labels:  neo4j, neo4j-driver, cypher
Scala Cypher Dsl
A type-safe Cypher Query Language DSL for Scala.
Stars: ✭ 34 (-37.04%)
Mutual labels:  neo4j, cypher
Neo4j Helm
Helm Charts for running Neo4j on Kubernetes
Stars: ✭ 43 (-20.37%)
Mutual labels:  neo4j, cypher
Cypher Stream
Neo4j Cypher queries as Node.js object streams
Stars: ✭ 58 (+7.41%)
Mutual labels:  neo4j, cypher
Neo4j
Graphs for Everyone
Stars: ✭ 9,582 (+17644.44%)
Mutual labels:  neo4j, cypher
Neovis.js
Neo4j + vis.js = neovis.js. Graph visualizations in the browser with data from Neo4j.
Stars: ✭ 748 (+1285.19%)
Mutual labels:  neo4j, cypher
Movies Java Bolt
Neo4j Movies Example application with SparkJava backend using the neo4j-java-driver
Stars: ✭ 66 (+22.22%)
Mutual labels:  neo4j, cypher
Cypher Dsl
A Java DSL for the Cypher Query Language
Stars: ✭ 116 (+114.81%)
Mutual labels:  neo4j, cypher
neo4j-jdbc
JDBC driver for Neo4j
Stars: ✭ 110 (+103.7%)
Mutual labels:  neo4j, neo4j-driver
R2d2 Cypher
Cypher support for the r2d2 connection pool
Stars: ✭ 8 (-85.19%)
Mutual labels:  neo4j, cypher
Neo4j Tableau
Neo4j Tableau Integration via WDC
Stars: ✭ 56 (+3.7%)
Mutual labels:  neo4j, cypher
Node Neo4j
[RETIRED] Neo4j graph database driver (REST API client) for Node.js
Stars: ✭ 935 (+1631.48%)
Mutual labels:  neo4j, cypher
Stock Knowledge Graph
利用网络上公开的数据构建一个小型的证券知识图谱/知识库
Stars: ✭ 1,182 (+2088.89%)
Mutual labels:  neo4j, cypher
Neo4j Etl
Data import from relational databases to Neo4j.
Stars: ✭ 165 (+205.56%)
Mutual labels:  neo4j, cypher
Neo4j 3d Force Graph
Experiments with Neo4j & 3d-force-graph https://github.com/vasturiano/3d-force-graph
Stars: ✭ 159 (+194.44%)
Mutual labels:  neo4j, cypher

No Maintenance Intended

⚠️ Deprecated ⚠️

This library is deprecated and will no longer be updated.

OGMNeo

Abstract some trivial operations on the Neo4j driver for Nodejs and make the use simpler. That's why we created OGMNeo.

npm version npm MIT Travis Codecov

Installation

You can find ogmneo in npm here and install using the follow command

 npm install ogmneo

Usage

Connecting to neo4j database

const ogmneo = require('ogmneo');
ogmneo.Connection.connect('neo4j', 'databasepass', 'localhost');
// Or if you want to add some neo4j driver configuration options 
ogmneo.Connection.connect('neo4j', 'databasepass', 'localhost', { maxTransactionRetryTime: 30000, encrypted: false });
// 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 = require('ogmneo');
ogmneo.Connection.logCypherEnabled = true;

Create node example

  const ogmneo = require('ogmneo');
  
  ogmneo.Node.create({ name: 'name', tes: 3 }, 'test')
  .then((node) => {
       //Created returned object => {id: 1, name: 'name', tes: 3}
  }).catch((error) => {
       //Handle error
  });

Find Nodes

  const ogmneo = require('ogmneo');
  
  let query = ogmneo.Query.create('test')
                             .where(new ogmneo.Where('name', { $eq: 'name1' }));

  ogmneo.Node.find(query)
  .then((nodes) => {
      //Found nodes.
  }).catch((error) => {
      //Handle error.
  });

Create relations

You can create relations between nodes.

  const ogmneo = require('ogmneo');
  ogmneo.Relation.relate(node1.id, 'relatedto', node2.id, {property: 'a'})
  .then((rels) => {
        // Created relation node {id: 2, type: 'relatedto', property: 'a'}
  }).catch((error) => {
        //Handle error
  });

Find Relations

You can find the relation nodes.

  const ogmneo = require('ogmneo');
  
  let query = ogmneo.RelationQuery.create('relatedto')
                                 .startNode(node1.id)
                                 .endNode(node2.id)
                                 .relationWhere(ogmneo.Where.create('property', { $eq: 'c' }))
                                 .ascOrderBy('property')
                                 .limit(3);
  ogmneo.Relation.find(query)
  .then((nodes) => {
        //Found relation nodes.
  }).catch((error) => {
        //Handle error.
  });
  
  //OR
  
  ogmneo.Relation.findPopulated(query)
  .then((nodes) => {
        //Found relation nodes with start and end nodes populated.
  }).catch((error) => {
        //Handle error.
  });
  

Executing Cypher

You can execute Cypher using the direct Neo4j Driver session object. Or you can use OGMNeoCypher.

  const ogmneo = require('ogmneo');

  ogmneo.Cypher.transactionalRead(cypherStatement)
  .then((result) => {
     console.log(result);
  }).catch((error) => {
     reject(error);
  });
  
  //OR
   ogmneo.Cypher.transactionalWrite(cypherStatement)
  .then((result) => {
     console.log(result);
  }).catch((error) => {
     reject(error);
  });
  

Creating and dropping indexes

You can create and drop indexes in properties.

  const ogmneo = require('ogmneo');
  //Creating
  ogmneo.Index.create('label', ['property'])
  .then((result) => {
     //Handle creation
  });
  //Dropping
  ogmneo.Index.drop('label', ['property'])
  .then((result) => {
     //Handle drop
  });

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 = require('ogmneo');
  
  let operation = ogmneo.Node.createOperation({ name: 'name', tes: 3 }, 'test');
  ogmneo.OperationExecuter.execute(operation)
  .then((node) => {
       //Created returned object => {id: 1, name: 'name', tes: 3}
  }).catch((error) => {
       //Handle error
  });

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 = require('ogmneo');
  
  let createDriver = ogmneo.Node.createOperation({name: 'Ayrton Senna', carNumber: 12 }, 'Driver');
  ogmneo.OperationExecuter.write((transaction) => {
        return ogmneo.OperationExecuter.execute(createDriver, transaction)
                               .then((driver) => {
                                    let createCar = ogmneo.Node.createOperation({name: 'MP4/4'}, 'Car');
                                    return ogmneo.OperationExecuter.execute(createCar, transaction).then((car) => {
                                       let relate = ogmneo.Relation.relateOperation(driver.id, 'DRIVES', car.id, {year: 1988});
                                       return ogmneo.OperationExecuter.execute(relate, transaction);
                                    });
                               });
    }).then((result) => {
       //Result here
    });

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 = require('ogmneo');
  
    let createUser1 = OGMNeoNode.createOperation({name: 'Ayrton Senna'}, 'Person');
    let createUser2 = OGMNeoNode.createOperation({name: 'Alain Prost'}, 'Person');

    ogmneo.OperationExecuter.batchWriteOperations([createUser1, createUser2]).then((result) => {
        let created1 = result[0];
        let created2 = result[1];
        console.log(created1.name); // 'Ayrton Senna'
        console.log(created2.name); // 'Alain Prost'
    });

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].