{"id":15266405,"url":"https://github.com/lucianopalmeida/ogmneo","last_synced_at":"2025-10-06T07:30:31.551Z","repository":{"id":57313795,"uuid":"88117953","full_name":"LucianoPAlmeida/OGMNeo","owner":"LucianoPAlmeida","description":"[No Maintenance] Neo4j nodeJS OGM(object-graph mapping) abstraction layer","archived":true,"fork":false,"pushed_at":"2020-03-23T19:36:16.000Z","size":792,"stargazers_count":54,"open_issues_count":0,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-16T09:38:39.914Z","etag":null,"topics":["batch","bolt","coverage","cypher","database","database-abstraction","es6","javascript","neo4j","neo4j-driver","nodejs","object-graph-mapper","ogm-neo4j","orm","transaction"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LucianoPAlmeida.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-13T02:47:59.000Z","updated_at":"2023-01-28T15:10:58.000Z","dependencies_parsed_at":"2022-08-25T20:40:43.862Z","dependency_job_id":null,"html_url":"https://github.com/LucianoPAlmeida/OGMNeo","commit_stats":null,"previous_names":["lucianopalmeida/ormneo"],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucianoPAlmeida%2FOGMNeo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucianoPAlmeida%2FOGMNeo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucianoPAlmeida%2FOGMNeo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucianoPAlmeida%2FOGMNeo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LucianoPAlmeida","download_url":"https://codeload.github.com/LucianoPAlmeida/OGMNeo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235510114,"owners_count":19001650,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["batch","bolt","coverage","cypher","database","database-abstraction","es6","javascript","neo4j","neo4j-driver","nodejs","object-graph-mapper","ogm-neo4j","orm","transaction"],"created_at":"2024-09-30T05:09:03.571Z","updated_at":"2025-10-06T07:30:26.244Z","avatar_url":"https://github.com/LucianoPAlmeida.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/)\n\n# :warning: Deprecated :warning:\n\nThis library is deprecated and will no longer be updated.\n\n# OGMNeo\n\nAbstract some trivial operations on the Neo4j driver for Nodejs and make the use simpler. That's why we created OGMNeo.\n\n[![npm version](https://badge.fury.io/js/ogmneo.svg)](https://badge.fury.io/js/ogmneo)\n[![npm](https://img.shields.io/npm/dt/ogmneo.svg)](https://www.npmjs.com/package/ogmneo)\n[![MIT](https://img.shields.io/badge/License-MIT-red.svg)](https://opensource.org/licenses/MIT)\n[![Travis](https://img.shields.io/travis/LucianoPAlmeida/OGMNeo.svg)](https://travis-ci.org/LucianoPAlmeida/OGMNeo?branch=master)\n[![Codecov](https://img.shields.io/codecov/c/github/LucianoPAlmeida/OGMNeo.svg)](https://codecov.io/gh/LucianoPAlmeida/OGMNeo)\n\n## Installation\n\nYou can find ogmneo in npm [here](https://www.npmjs.com/package/ogmneo) and install using the follow command\n```sh\n npm install ogmneo\n```\n## Usage \n\n### Connecting to neo4j database\n\n```js\nconst ogmneo = require('ogmneo');\nogmneo.Connection.connect('neo4j', 'databasepass', 'localhost');\n// Or if you want to add some neo4j driver configuration options \nogmneo.Connection.connect('neo4j', 'databasepass', 'localhost', { maxTransactionRetryTime: 30000, encrypted: false });\n// See more about the config options you can add on: http://neo4j.com/docs/api/javascript-driver/current/function/index.html#static-function-driver\n\n```\n   OGMNeo connects using the neo4j bolt protocol.\n   \n### Log generated cypher on console\n\nYou can see the generated Cypher on your console by setting Connection.logCypherEnabled property true.\n\n```js\nconst ogmneo = require('ogmneo');\nogmneo.Connection.logCypherEnabled = true;\n\n```\n   \n### Create node example\n\n```js\n  const ogmneo = require('ogmneo');\n  \n  ogmneo.Node.create({ name: 'name', tes: 3 }, 'test')\n  .then((node) =\u003e {\n       //Created returned object =\u003e {id: 1, name: 'name', tes: 3}\n  }).catch((error) =\u003e {\n       //Handle error\n  });\n```\n\n### Find Nodes \n  ```js\n    const ogmneo = require('ogmneo');\n    \n    let query = ogmneo.Query.create('test')\n                               .where(new ogmneo.Where('name', { $eq: 'name1' }));\n\n    ogmneo.Node.find(query)\n    .then((nodes) =\u003e {\n        //Found nodes.\n    }).catch((error) =\u003e {\n        //Handle error.\n    });\n  ```\n### Create relations\nYou can create relations between nodes.\n\n```js\n  const ogmneo = require('ogmneo');\n  ogmneo.Relation.relate(node1.id, 'relatedto', node2.id, {property: 'a'})\n  .then((rels) =\u003e {\n        // Created relation node {id: 2, type: 'relatedto', property: 'a'}\n  }).catch((error) =\u003e {\n        //Handle error\n  });\n```\n\n## Find Relations \nYou can find the relation nodes.\n\n```js\n  const ogmneo = require('ogmneo');\n  \n  let query = ogmneo.RelationQuery.create('relatedto')\n                                 .startNode(node1.id)\n                                 .endNode(node2.id)\n                                 .relationWhere(ogmneo.Where.create('property', { $eq: 'c' }))\n                                 .ascOrderBy('property')\n                                 .limit(3);\n  ogmneo.Relation.find(query)\n  .then((nodes) =\u003e {\n        //Found relation nodes.\n  }).catch((error) =\u003e {\n        //Handle error.\n  });\n  \n  //OR\n  \n  ogmneo.Relation.findPopulated(query)\n  .then((nodes) =\u003e {\n        //Found relation nodes with start and end nodes populated.\n  }).catch((error) =\u003e {\n        //Handle error.\n  });\n  \n```\n\n## Executing Cypher\nYou can execute Cypher using the direct [Neo4j Driver](https://github.com/neo4j/neo4j-javascript-driver) session object. Or you can use OGMNeoCypher.\n\n```js\n  const ogmneo = require('ogmneo');\n\n  ogmneo.Cypher.transactionalRead(cypherStatement)\n  .then((result) =\u003e {\n     console.log(result);\n  }).catch((error) =\u003e {\n     reject(error);\n  });\n  \n  //OR\n   ogmneo.Cypher.transactionalWrite(cypherStatement)\n  .then((result) =\u003e {\n     console.log(result);\n  }).catch((error) =\u003e {\n     reject(error);\n  });\n  \n``` \n## Creating and dropping indexes\nYou can create and drop indexes in properties.\n\n```js\n  const ogmneo = require('ogmneo');\n  //Creating\n  ogmneo.Index.create('label', ['property'])\n  .then((result) =\u003e {\n     //Handle creation\n  });\n  //Dropping\n  ogmneo.Index.drop('label', ['property'])\n  .then((result) =\u003e {\n     //Handle drop\n  });\n``` \n\n## Operation API\n\nAlmost 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:\n```js\n  const ogmneo = require('ogmneo');\n  \n  let operation = ogmneo.Node.createOperation({ name: 'name', tes: 3 }, 'test');\n  ogmneo.OperationExecuter.execute(operation)\n  .then((node) =\u003e {\n       //Created returned object =\u003e {id: 1, name: 'name', tes: 3}\n  }).catch((error) =\u003e {\n       //Handle error\n  });\n```\n\n## Transactional API \n\nWith the Operation API we can now execute as many READ or WRITE operations on the same transaction.\nFor example, you want to create nodes and then relate those two. But if the relationship operation fails you want to rollback all the operations.\n\n```js\n  const ogmneo = require('ogmneo');\n  \n  let createDriver = ogmneo.Node.createOperation({name: 'Ayrton Senna', carNumber: 12 }, 'Driver');\n  ogmneo.OperationExecuter.write((transaction) =\u003e {\n        return ogmneo.OperationExecuter.execute(createDriver, transaction)\n                               .then((driver) =\u003e {\n                                    let createCar = ogmneo.Node.createOperation({name: 'MP4/4'}, 'Car');\n                                    return ogmneo.OperationExecuter.execute(createCar, transaction).then((car) =\u003e {\n                                       let relate = ogmneo.Relation.relateOperation(driver.id, 'DRIVES', car.id, {year: 1988});\n                                       return ogmneo.OperationExecuter.execute(relate, transaction);\n                                    });\n                               });\n    }).then((result) =\u003e {\n       //Result here\n    });\n```\nAll of those operations will be executed on the same transaction and you can rollback anytime you want. The transaction is the [neo4j driver](https://github.com/neo4j/neo4j-javascript-driver) transaction object and you can see more about it on their docs [here](http://neo4j.com/docs/api/javascript-driver/current/class/src/v1/transaction.js~Transaction.html).\n\n### Batching operation in a single transaction\n\nYou can also batch many operation READ or WRITE operations in a single transaction.\n\n```js\n    const ogmneo = require('ogmneo');\n  \n    let createUser1 = OGMNeoNode.createOperation({name: 'Ayrton Senna'}, 'Person');\n    let createUser2 = OGMNeoNode.createOperation({name: 'Alain Prost'}, 'Person');\n\n    ogmneo.OperationExecuter.batchWriteOperations([createUser1, createUser2]).then((result) =\u003e {\n        let created1 = result[0];\n        let created2 = result[1];\n        console.log(created1.name); // 'Ayrton Senna'\n        console.log(created2.name); // 'Alain Prost'\n    });\n```\nIf one of those fails, all other operations on the transaction will be rolledback automatically.\n\n## Documentation\n\n  See the full **API** documentation at [docs](http://ogmneo-docs.getforge.io/). All docs was generated by [JSDoc](https://github.com/jsdoc3/jsdoc).\n  \n## Exemple \n  \n  See a demo sample on the [ogmneo-demo repository](https://github.com/LucianoPAlmeida/ogmneo-demo).\n  \n## Tests\n\n  Most of this library functions are covered by unit tests.\n  See the code coverage on [codecov.io](https://codecov.io/gh/LucianoPAlmeida/OGMNeo).\n\n## Licence\n\nOGMNeo is released under the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucianopalmeida%2Fogmneo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucianopalmeida%2Fogmneo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucianopalmeida%2Fogmneo/lists"}