{"_id":"@bryanph/neo4j-driver","_rev":"2-919ef3cf22ae4ecc29acfae5547e4363","name":"@bryanph/neo4j-driver","description":"Connect to Neo4j 3.1.0 and up from JavaScript","dist-tags":{"latest":"1.2.0-dev"},"versions":{"1.2.0-dev":{"name":"@bryanph/neo4j-driver","version":"1.2.0-dev","description":"Connect to Neo4j 3.1.0 and up from JavaScript","author":{"name":"Neo Technology Inc."},"license":"Apache-2.0","repository":{"type":"git","url":"git://github.com/neo4j/neo4j-javascript-driver.git"},"scripts":{"test":"gulp test","boltkit":"gulp test-boltkit","build":"gulp all","start-neo4j":"gulp start-neo4j","stop-neo4j":"gulp stop-neo4j","run-stress-tests":"gulp run-stress-tests","run-tck":"gulp run-tck","run-ts-declaration-tests":"gulp run-ts-declaration-tests","docs":"esdoc -c esdoc.json","versionRelease":"gulp set --version $VERSION && npm version $VERSION --no-git-tag-version"},"main":"lib/index.js","types":"types/index.d.ts","devDependencies":{"async":"^2.4.0","babel-core":"^6.17.0","babel-plugin-transform-runtime":"^6.15.0","babel-preset-es2015":"^6.16.0","babel-preset-stage-3":"^6.17.0","babel-register":"^6.18.0","babelify":"^7.3.0","browserify":"^13.1.0","esdoc":"0.4.8","esdoc-importpath-plugin":"0.1.1","fs-extra":"^1.0.0","gulp":"^3.9.1","gulp-babel":"^6.1.2","gulp-batch":"^1.0.5","gulp-cucumber":"0.0.14","gulp-decompress":"^1.2.0","gulp-download":"^0.0.1","gulp-file":"^0.3.0","gulp-install":"^0.6.0","gulp-jasmine":"^2.1.0","gulp-jasmine-browser":"^0.2.3","gulp-replace":"^0.5.4","gulp-typescript":"^3.1.7","gulp-uglify":"^1.4.2","gulp-util":"^3.0.6","gulp-watch":"^4.3.5","lodash":"^4.17.4","lolex":"^1.5.2","minimist":"^1.2.0","mustache":"^2.3.0","phantomjs-prebuilt":"^2.1.7 ","run-sequence":"^1.1.4","semver":"^5.3.0","through2":"~2.0.0","tmp":"0.0.31","typescript":"^2.3.4","vinyl-buffer":"^1.0.0","vinyl-source-stream":"^1.1.0"},"dependencies":{"babel-runtime":"^6.18.0"},"gitHead":"9f9d64491c83a75de3ee207a85fd9fbb69f38597","bugs":{"url":"https://github.com/neo4j/neo4j-javascript-driver/issues"},"homepage":"https://github.com/neo4j/neo4j-javascript-driver#readme","_id":"@bryanph/neo4j-driver@1.2.0-dev","_shasum":"02c7aa11b240849dd7a6be8cecc8e2ed8e17bf41","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.10.0","_npmUser":{"name":"bryanph","email":"bryanhaakman@gmail.com"},"dist":{"shasum":"02c7aa11b240849dd7a6be8cecc8e2ed8e17bf41","tarball":"https://registry.npmjs.org/@bryanph/neo4j-driver/-/neo4j-driver-1.2.0-dev.tgz","integrity":"sha512-ZoK5X/hKaIZs6f3kWV26LD7cVnykQ//FixsRnqsEk1w78eZwwJag6k1tyiOy8U/7WZpYGB9G/ZO4J2kQpqNVVA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDKtbMwdpxMR40stYXZSbm38sUVbaCmPeSVvYlOBC7vbgIgHxZ49P8ySICySHg0RZSg28uupWzcAqy3Wi3KjcGRouk="}]},"maintainers":[{"name":"bryanph","email":"bryanhaakman@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/neo4j-driver-1.2.0-dev.tgz_1509035481174_0.8686382141895592"}}},"readme":"# Neo4j Driver for Javascript\n\n\nA database driver for Neo4j 3.0.0+.\n\nResources to get you started:\n\n* [Detailed docs](http://neo4j.com/docs/api/javascript-driver/current/).\n* [Sample small project using the driver](https://github.com/neo4j-examples/movies-javascript-bolt)\n* [Sample application using the driver](https://github.com/neo4j-examples/neo4j-movies-template)\n* [Neo4j Manual](https://neo4j.com/docs/)\n* [Neo4j Refcard](https://neo4j.com/docs/cypher-refcard/current/)\n\n## Include module in Node.js application\n\nStable channel:\n```shell\nnpm install neo4j-driver\n// or\nbower install neo4j-driver\n```\n\nPre-release channel:\n```shell\nnpm install neo4j-driver@next\n```\n\nPlease note that `@next` only points to pre-releases that are not suitable for production use.\nTo get the latest stable release omit `@next` part altogether or use `@latest` instead.\n\n```javascript\nvar neo4j = require('neo4j-driver').v1;\n```\nDriver instance should be closed when Node.js application exits:\n\n```javascript\ndriver.close();\n```\n\notherwise application shutdown might hang or it might exit with a non-zero exit code.\n\n## Include in web browser\n\nWe build a special browser version of the driver, which supports connecting to Neo4j over WebSockets.\n\n```html\n<script src=\"lib/browser/neo4j-web.min.js\"></script>\n```\n\nThis will make a global `neo4j` object available, where you can access the `v1` API at `neo4j.v1`:\n\n```javascript\nvar driver = neo4j.driver(\"bolt://localhost\", neo4j.auth.basic(\"neo4j\", \"neo4j\"));\n```\n\nIt is not required to explicitly close the driver on a web page. Web browser should gracefully close all open \nWebSockets when the page is unloaded. However, driver instance should be explicitly closed when it's lifetime\nis not the same as the lifetime of the web page:\n \n```javascript\ndriver.close();\n```\n\n## Usage examples\n\nDriver creation:\n```javascript\n// Create a driver instance, for the user neo4j with password neo4j.\n// It should be enough to have a single driver per database per application.\nvar driver = neo4j.driver(\"bolt://localhost\", neo4j.auth.basic(\"neo4j\", \"neo4j\"));\n\n// Register a callback to know if driver creation was successful:\ndriver.onCompleted = function () {\n  // proceed with using the driver, it was successfully instantiated\n};\n\n// Register a callback to know if driver creation failed.\n// This could happen due to wrong credentials or database unavailability:\ndriver.onError = function (error) {\n  console.log('Driver instantiation failed', error);\n};\n\n// Close the driver when application exits.\n// This closes all used network connections.\ndriver.close();\n```\n\nSession API:\n```javascript\n// Create a session to run Cypher statements in.\n// Note: Always make sure to close sessions when you are done using them!\nvar session = driver.session();\n\n// Run a Cypher statement, reading the result in a streaming manner as records arrive:\nsession\n  .run('MERGE (alice:Person {name : {nameParam} }) RETURN alice.name AS name', {nameParam: 'Alice'})\n  .subscribe({\n    onNext: function (record) {\n      console.log(record.get('name'));\n    },\n    onCompleted: function () {\n      session.close();\n    },\n    onError: function (error) {\n      console.log(error);\n    }\n  });\n\n// or\n// the Promise way, where the complete result is collected before we act on it:\nsession\n  .run('MERGE (james:Person {name : {nameParam} }) RETURN james.name AS name', {nameParam: 'James'})\n  .then(function (result) {\n    result.records.forEach(function (record) {\n      console.log(record.get('name'));\n    });\n    session.close();\n  })\n  .catch(function (error) {\n    console.log(error);\n  });\n```\n\nTransaction functions API:\n```javascript\n// Transaction functions provide a convenient API with minimal boilerplate and\n// retries on network fluctuations and transient errors. Maximum retry time is\n// configured on the driver level and is 30 seconds by default:\nneo4j.driver(\"bolt://localhost\", neo4j.auth.basic(\"neo4j\", \"neo4j\"), {maxTransactionRetryTime: 30000});\n\n// It is possible to execute read transactions that will benefit from automatic\n// retries on both single instance ('bolt' URI scheme) and Causal Cluster\n// ('bolt+routing' URI scheme) and will get automatic load balancing in cluster deployments\nvar readTxResultPromise = session.readTransaction(function (transaction) {\n  // used transaction will be committed automatically, no need for explicit commit/rollback\n\n  var result = transaction.run('MATCH (person:Person) RETURN person.name AS name');\n  // at this point it is possible to either return the result or process it and return the\n  // result of processing it is also possible to run more statements in the same transaction\n  return result;\n});\n\n// returned Promise can be later consumed like this:\nreadTxResultPromise.then(function (result) {\n  session.close();\n  console.log(result.records);\n}).catch(function (error) {\n  console.log(error);\n});\n\n// It is possible to execute write transactions that will benefit from automatic retries\n// on both single instance ('bolt' URI scheme) and Causal Cluster ('bolt+routing' URI scheme)\nvar writeTxResultPromise = session.writeTransaction(function (transaction) {\n  // used transaction will be committed automatically, no need for explicit commit/rollback\n\n  var result = transaction.run('MERGE (alice:Person {name : \\'Alice\\' }) RETURN alice.name AS name');\n  // at this point it is possible to either return the result or process it and return the\n  // result of processing it is also possible to run more statements in the same transaction\n  return result.records.map(function (record) {\n    return record.get('name');\n  });\n});\n\n// returned Promise can be later consumed like this:\nwriteTxResultPromise.then(function (namesArray) {\n  session.close();\n  console.log(namesArray);\n}).catch(function (error) {\n  console.log(error);\n});\n```\n\nExplicit transactions API:\n```javascript\n// run statement in a transaction\nvar tx = session.beginTransaction();\ntx.run(\"MERGE (bob:Person {name : {nameParam} }) RETURN bob.name AS name\", {nameParam: 'Bob'})\n  .subscribe({\n    onNext: function (record) {\n      console.log(record.get('name'));\n    },\n    onCompleted: function () {\n      session.close();\n    },\n    onError: function (error) {\n      console.log(error);\n    }\n  });\n\n//decide if the transaction should be committed or rolled back\nvar success = false;\n\nif (success) {\n  tx.commit()\n    .subscribe({\n      onCompleted: function () {\n        // this transaction is now committed \n      },\n      onError: function (error) {\n        console.log(error);\n      }\n    });\n} else {\n  //transaction is rolled black and nothing is created in the database\n  console.log('rolled back');\n  tx.rollback();\n}\n```\n\nSubscriber API allows following combinations of `onNext`, `onCompleted` and `onError` callback invocations:\n * zero or more `onNext` followed by `onCompleted` when operation was successful. `onError` will not be invoked \n in this case\n * zero or more `onNext` followed by `onError` when operation failed. Callback `onError` might be invoked after \n couple `onNext` invocations because records are streamed lazily by the database. `onCompleted` will not be invoked \n in this case\n\n## Building\n\n    npm install\n    npm build\n\nThis produces browser-compatible standalone files under `lib/browser` and a Node.js module version under `lib/`.\nSee files under `examples/` on how to use.\n\n## Testing\n\nTests **require** latest [Boltkit](https://github.com/neo4j-contrib/boltkit) to be installed in the system. It is needed to start, stop and configure local test database. Boltkit can be installed with the following command:\n\n    pip install --upgrade boltkit\n\nTo run tests against \"default\" Neo4j version:\n\n    ./runTests.sh\n    \nTo run tests against specified Neo4j version:\n    \n    ./runTests.sh '-e 3.1.3'\n\nSimple `npm test` can also be used if you already have a running version of a compatible Neo4j server.\n\nFor development, you can have the build tool rerun the tests each time you change\nthe source code:\n\n    gulp watch-n-test\n\n### Testing on windows\nRunning tests on windows requires PhantomJS installed and its bin folder added in windows system variable `Path`.\nTo run the same test suite, run `.\\runTest.ps1` instead in powershell with admin right.\nThe admin right is required to start/stop Neo4j properly as a system service.\nWhile there is no need to grab admin right if you are running tests against an existing Neo4j server using `npm test`.\n\n## A note on numbers and the Integer type\nThe Neo4j type system includes 64-bit integer values.\nHowever, Javascript can only safely represent integers between `-(2`<sup>`53`</sup>` - 1)` and `(2`<sup>`53`</sup>` - 1)`.\nIn order to support the full Neo4j type system, the driver will not automatically convert to javascript integers.\nAny time the driver receives an integer value from Neo4j, it will be represented with an internal integer type by the driver.\n\n### Write integers\nNumber written directly e.g. `session.run(\"CREATE (n:Node {age: {age}})\", {age: 22})` will be of type `Float` in Neo4j.\nTo write the `age` as an integer the `neo4j.int` method should be used:\n\n```javascript\nvar neo4j = require('neo4j-driver').v1;\n\nsession.run(\"CREATE (n {age: {myIntParam}})\", {myIntParam: neo4j.int(22)});\n```\n\nTo write integers larger than can be represented as JavaScript numbers, use a string argument to `neo4j.int`:\n\n```javascript\nsession.run(\"CREATE (n {age: {myIntParam}})\", {myIntParam: neo4j.int(\"9223372036854775807\")});\n```\n\n### Read integers\nSince Integers can be larger than can be represented as JavaScript numbers, it is only safe to convert to JavaScript numbers if you know that they will not exceed `(2`<sup>`53`</sup>` - 1)` in size.\nIn order to facilitate working with integers the driver include `neo4j.isInt`, `neo4j.integer.inSafeRange`, `neo4j.integer.toNumber`, and `neo4j.integer.toString`.\n\n```javascript\nvar aSmallInteger = neo4j.int(123);\nif (neo4j.integer.inSafeRange(aSmallInteger)) {\n    var aNumber = aSmallInteger.toNumber();\n}\n```\n\nIf you will be handling integers larger than that, you should convert them to strings:\n\n```javascript\nvar aLargerInteger = neo4j.int(\"9223372036854775807\");\nif (!neo4j.integer.inSafeRange(aSmallInteger)) {\n    var integerAsString = aLargerInteger.toString();\n}\n```\n\n","maintainers":[{"name":"bryanph","email":"bryanhaakman@gmail.com"}],"time":{"modified":"2022-06-12T15:31:20.838Z","created":"2017-10-26T16:31:22.822Z","1.2.0-dev":"2017-10-26T16:31:22.822Z"},"homepage":"https://github.com/neo4j/neo4j-javascript-driver#readme","repository":{"type":"git","url":"git://github.com/neo4j/neo4j-javascript-driver.git"},"author":{"name":"Neo Technology Inc."},"bugs":{"url":"https://github.com/neo4j/neo4j-javascript-driver/issues"},"license":"Apache-2.0","readmeFilename":"README.md"}