Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cypher-stream

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cypher-stream - npm Package Compare versions

Comparing version 1.0.0-alpha to 1.0.1-alpha

20

CypherStream.js

@@ -20,5 +20,2 @@ 'use strict';

// Recursively map Neo4j values
// to their native equivalants
// session => statement => observable

@@ -52,6 +49,7 @@ var run = curry((runner, statement) =>

constructor(runner, statements) {
constructor(runner, statements, options) {
super({ objectMode: true });
this.statements = statements;
this.runner = runner;
this.runner = runner;
this.options = options || {};
this.start();

@@ -65,9 +63,15 @@ }

.flatMap(statement => {
var stream =
runStream(this.runner, statement)
.map(toNative);
var stream = runStream(this.runner, statement);
if('neo4j' !== this.options.returnType) {
stream = stream.map(toNative);
}
if(statement.callback) {
statement.callback(stream.observe());
}
return stream;
})

@@ -74,0 +78,0 @@ .errors(handleError(emitError(this)))

4

index.js

@@ -28,3 +28,3 @@ 'use strict';

var factory = function CypherStreamFactory(statement, parameters) {
var factory = function CypherStreamFactory(statement, parameters, options) {
if (parameters) {

@@ -34,3 +34,3 @@ statement = [ { statement, parameters } ];

var session = driver.session();
return new CypherStream(session, statement)
return new CypherStream(session, statement, options)
.on('end', () => session.close());

@@ -37,0 +37,0 @@ };

{
"name": "cypher-stream",
"version": "1.0.0-alpha",
"version": "1.0.1-alpha",
"description": "Streams cypher query results in a clean format",

@@ -27,12 +27,11 @@ "main": "index.js",

"neo4j-driver": "^1.0.3",
"oboe": "^2.1.1",
"ramda": "^0.21.0"
"ramda": "^0.22.1"
},
"devDependencies": {
"coveralls": "^2.11.2",
"mocha-lcov-reporter": "0.0.1",
"mocha": "~1.17.1",
"should": "~3.1.3",
"istanbul": "^0.3.2"
"mocha-lcov-reporter": "1.2.0",
"mocha": "~3.0.2",
"should": "~11.1.0",
"istanbul": "^0.4.4"
}
}

@@ -7,2 +7,16 @@ # cypher-stream

## 1.0.0-alpha
1.0.0-alpha is Powered by Bolt™. Updated documentation is forthcoming. For the brave, check the source, tests, and go wild.
The API is largely unchanged, with the exception of authentication and some configuration options which no longer make sense in the Bolt world (i.e. http headers).
Performance should be significantly improved, given that the library no longer has to stream-parse HTTP JSON responses.
TODO:
* Documentation / Migration guide
* Facilitate access to underlying Neo4j objects
* Benchmark
## Installation

@@ -13,6 +27,12 @@ ```

Or, for Bolt
```
npm install cypher-stream@1.0.0-alpha
```
## Basic usage
``` js
var cypher = require('cypher-stream')('http://localhost:7474');
var cypher = require('cypher-stream')('bolt://localhost', 'username', 'password');

@@ -31,3 +51,3 @@ cypher('match (user:User) return user')

``` js
var cypher = require('cypher-stream')('http://localhost:7474');
var cypher = require('cypher-stream')('bolt://localhost', 'username', 'password');
var should = require('should');

@@ -96,3 +116,2 @@ it('handles errors', function (done) {

``` js

@@ -115,20 +134,2 @@ transaction.commit();

### Query Batching
Transactions automatically batch queries for significant performance gains. Try the following:
``` js
var queriesToRun = 10000;
var queriesWritten = 0;
var transaction = cypher.transaction()
.on('data', function (result) {
console.log(result);
})
;
while (queriesWritten++ < queriesToRun) {
transaction.write('match (n:Test) return n limit 1');
}
transaction.commit();
```
## Stream per statement

@@ -135,0 +136,0 @@

'use strict';
var cypher = require('../index')('bolt://0.0.0.0');
var neo4j = require('neo4j-driver').v1;
var R = require('ramda');
var should = require('should');
var R = require('ramda');

@@ -183,2 +184,17 @@ var shouldNotError = error => should.not.exist(error);

it('can optionally return Neo4j data types', done => {
cypher(`match (n:Test) return n limit 1`, {}, { returnType: 'neo4j' })
.on('data', data => {
data.should.have.properties([
'_fields',
'keys',
'length',
'_fieldLookup',
]);
})
.on('end', done)
;
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc