Giter Site home page Giter Site logo

neo4j-stream-deserializer's Introduction

neo4j-stream-deserializer Build Status devDependency Status

Project no longer maintained since cypher-stream now depends on oboe.js instead.

Streams neo4j responses as formatted objects.

A typical neo4j response:

{"columns":["n"],"data":[[{"extensions":{},"paged_traverse":"http://localhost:7474/db/data/node/4307/paged/traverse/{returnType}{?pageSize,leaseTime}","labels":"http://localhost:7474/db/data/node/4307/labels","outgoing_relationships":"http://localhost:7474/db/data/node/4307/relationships/out","traverse":"http://localhost:7474/db/data/node/4307/traverse/{returnType}","all_typed_relationships":"http://localhost:7474/db/data/node/4307/relationships/all/{-list|&|types}","property":"http://localhost:7474/db/data/node/4307/properties/{key}","all_relationships":"http://localhost:7474/db/data/node/4307/relationships/all","self":"http://localhost:7474/db/data/node/4307","properties":"http://localhost:7474/db/data/node/4307/properties","outgoing_typed_relationships":"http://localhost:7474/db/data/node/4307/relationships/out/{-list|&|types}","incoming_relationships":"http://localhost:7474/db/data/node/4307/relationships/in","incoming_typed_relationships":"http://localhost:7474/db/data/node/4307/relationships/in/{-list|&|types}","create_relationship":"http://localhost:7474/db/data/node/4307/relationships","data":{"test":true,"uuid":"27d1b700-88aa-11e3-9992-d7608d571cea"}}],[{"extensions":{},"paged_traverse":"http://localhost:7474/db/data/node/4308/paged/traverse/{returnType}{?pageSize,leaseTime}","labels":"http://localhost:7474/db/data/node/4308/labels","outgoing_relationships":"http://localhost:7474/db/data/node/4308/relationships/out","traverse":"http://localhost:7474/db/data/node/4308/traverse/{returnType}","all_typed_relationships":"http://localhost:7474/db/data/node/4308/relationships/all/{-list|&|types}","property":"http://localhost:7474/db/data/node/4308/properties/{key}","all_relationships":"http://localhost:7474/db/data/node/4308/relationships/all","self":"http://localhost:7474/db/data/node/4308","properties":"http://localhost:7474/db/data/node/4308/properties","outgoing_typed_relationships":"http://localhost:7474/db/data/node/4308/relationships/out/{-list|&|types}","incoming_relationships":"http://localhost:7474/db/data/node/4308/relationships/in","incoming_typed_relationships":"http://localhost:7474/db/data/node/4308/relationships/in/{-list|&|types}","create_relationship":"http://localhost:7474/db/data/node/4308/relationships","data":{"test":true,"uuid":"2ed844b0-88aa-11e3-9992-d7608d571cea"}}],[{"extensions":{},"paged_traverse":"http://localhost:7474/db/data/node/4309/paged/traverse/{returnType}{?pageSize,leaseTime}","labels":"http://localhost:7474/db/data/node/4309/labels","outgoing_relationships":"http://localhost:7474/db/data/node/4309/relationships/out","traverse":"http://localhost:7474/db/data/node/4309/traverse/{returnType}","all_typed_relationships":"http://localhost:7474/db/data/node/4309/relationships/all/{-list|&|types}","property":"http://localhost:7474/db/data/node/4309/properties/{key}","all_relationships":"http://localhost:7474/db/data/node/4309/relationships/all","self":"http://localhost:7474/db/data/node/4309","properties":"http://localhost:7474/db/data/node/4309/properties","outgoing_typed_relationships":"http://localhost:7474/db/data/node/4309/relationships/out/{-list|&|types}","incoming_relationships":"http://localhost:7474/db/data/node/4309/relationships/in","incoming_typed_relationships":"http://localhost:7474/db/data/node/4309/relationships/in/{-list|&|types}","create_relationship":"http://localhost:7474/db/data/node/4309/relationships","data":{"test":true,"uuid":"36204830-88aa-11e3-9992-d7608d571cea"}}],[{"extensions":{},"paged_traverse":"http://localhost:7474/db/data/node/4310/paged/traverse/{returnType}{?pageSize,leaseTime}","labels":"http://localhost:7474/db/data/node/4310/labels","outgoing_relationships":"http://localhost:7474/db/data/node/4310/relationships/out","traverse":"http://localhost:7474/db/data/node/4310/traverse/{returnType}","all_typed_relationships":"http://localhost:7474/db/data/node/4310/relationships/all/{-list|&|types}","property":"http://localhost:7474/db/data/node/4310/properties/{key}","all_relationships":"http://localhost:7474/db/data/node/4310/relationships/all","self":"http://localhost:7474/db/data/node/4310","properties":"http://localhost:7474/db/data/node/4310/properties","outgoing_typed_relationships":"http://localhost:7474/db/data/node/4310/relationships/out/{-list|&|types}","incoming_relationships":"http://localhost:7474/db/data/node/4310/relationships/in","incoming_typed_relationships":"http://localhost:7474/db/data/node/4310/relationships/in/{-list|&|types}","create_relationship":"http://localhost:7474/db/data/node/4310/relationships","data":{"test":true,"uuid":"3c4bdf30-88aa-11e3-9992-d7608d571cea"}}],[{"extensions":{},"paged_traverse":"http://localhost:7474/db/data/node/4311/paged/traverse/{returnType}{?pageSize,leaseTime}","labels":"http://localhost:7474/db/data/node/4311/labels","outgoing_relationships":"http://localhost:7474/db/data/node/4311/relationships/out","traverse":"http://localhost:7474/db/data/node/4311/traverse/{returnType}","all_typed_relationships":"http://localhost:7474/db/data/node/4311/relationships/all/{-list|&|types}","property":"http://localhost:7474/db/data/node/4311/properties/{key}","all_relationships":"http://localhost:7474/db/data/node/4311/relationships/all","self":"http://localhost:7474/db/data/node/4311","properties":"http://localhost:7474/db/data/node/4311/properties","outgoing_typed_relationships":"http://localhost:7474/db/data/node/4311/relationships/out/{-list|&|types}","incoming_relationships":"http://localhost:7474/db/data/node/4311/relationships/in","incoming_typed_relationships":"http://localhost:7474/db/data/node/4311/relationships/in/{-list|&|types}","create_relationship":"http://localhost:7474/db/data/node/4311/relationships","data":{"test":true,"uuid":"43245800-88aa-11e3-9992-d7608d571cea"}}],[{"extensions":{},"paged_traverse":"http://localhost:7474/db/data/node/4312/paged/traverse/{returnType}{?pageSize,leaseTime}","labels":"http://localhost:7474/db/data/node/4312/labels","outgoing_relationships":"http://localhost:7474/db/data/node/4312/relationships/out","traverse":"http://localhost:7474/db/data/node/4312/traverse/{returnType}","all_typed_relationships":"http://localhost:7474/db/data/node/4312/relationships/all/{-list|&|types}","property":"http://localhost:7474/db/data/node/4312/properties/{key}","all_relationships":"http://localhost:7474/db/data/node/4312/relationships/all","self":"http://localhost:7474/db/data/node/4312","properties":"http://localhost:7474/db/data/node/4312/properties","outgoing_typed_relationships":"http://localhost:7474/db/data/node/4312/relationships/out/{-list|&|types}","incoming_relationships":"http://localhost:7474/db/data/node/4312/relationships/in","incoming_typed_relationships":"http://localhost:7474/db/data/node/4312/relationships/in/{-list|&|types}","create_relationship":"http://localhost:7474/db/data/node/4312/relationships","data":{"test":true,"uuid":"4a41c910-88aa-11e3-9992-d7608d571cea"}}],[{"extensions":{},"paged_traverse":"http://localhost:7474/db/data/node/4313/paged/traverse/{returnType}{?pageSize,leaseTime}","labels":"http://localhost:7474/db/data/node/4313/labels","outgoing_relationships":"http://localhost:7474/db/data/node/4313/relationships/out","traverse":"http://localhost:7474/db/data/node/4313/traverse/{returnType}","all_typed_relationships":"http://localhost:7474/db/data/node/4313/relationships/all/{-list|&|types}","property":"http://localhost:7474/db/data/node/4313/properties/{key}","all_relationships":"http://localhost:7474/db/data/node/4313/relationships/all","self":"http://localhost:7474/db/data/node/4313","properties":"http://localhost:7474/db/data/node/4313/properties","outgoing_typed_relationships":"http://localhost:7474/db/data/node/4313/relationships/out/{-list|&|types}","incoming_relationships":"http://localhost:7474/db/data/node/4313/relationships/in","incoming_typed_relationships":"http://localhost:7474/db/data/node/4313/relationships/in/{-list|&|types}","create_relationship":"http://localhost:7474/db/data/node/4313/relationships","data":{"test":true,"uuid":"50743de0-88aa-11e3-9992-d7608d571cea"}}],[{"extensions":{},"paged_traverse":"http://localhost:7474/db/data/node/4314/paged/traverse/{returnType}{?pageSize,leaseTime}","labels":"http://localhost:7474/db/data/node/4314/labels","outgoing_relationships":"http://localhost:7474/db/data/node/4314/relationships/out","traverse":"http://localhost:7474/db/data/node/4314/traverse/{returnType}","all_typed_relationships":"http://localhost:7474/db/data/node/4314/relationships/all/{-list|&|types}","property":"http://localhost:7474/db/data/node/4314/properties/{key}","all_relationships":"http://localhost:7474/db/data/node/4314/relationships/all","self":"http://localhost:7474/db/data/node/4314","properties":"http://localhost:7474/db/data/node/4314/properties","outgoing_typed_relationships":"http://localhost:7474/db/data/node/4314/relationships/out/{-list|&|types}","incoming_relationships":"http://localhost:7474/db/data/node/4314/relationships/in","incoming_typed_relationships":"http://localhost:7474/db/data/node/4314/relationships/in/{-list|&|types}","create_relationship":"http://localhost:7474/db/data/node/4314/relationships","data":{"test":true,"uuid":"56d7fbe0-88aa-11e3-9992-d7608d571cea"}}],[{"extensions":{},"paged_traverse":"http://localhost:7474/db/data/node/4315/paged/traverse/{returnType}{?pageSize,leaseTime}","labels":"http://localhost:7474/db/data/node/4315/labels","outgoing_relationships":"http://localhost:7474/db/data/node/4315/relationships/out","traverse":"http://localhost:7474/db/data/node/4315/traverse/{returnType}","all_typed_relationships":"http://localhost:7474/db/data/node/4315/relationships/all/{-list|&|types}","property":"http://localhost:7474/db/data/node/4315/properties/{key}","all_relationships":"http://localhost:7474/db/data/node/4315/relationships/all","self":"http://localhost:7474/db/data/node/4315","properties":"http://localhost:7474/db/data/node/4315/properties","outgoing_typed_relationships":"http://localhost:7474/db/data/node/4315/relationships/out/{-list|&|types}","incoming_relationships":"http://localhost:7474/db/data/node/4315/relationships/in","incoming_typed_relationships":"http://localhost:7474/db/data/node/4315/relationships/in/{-list|&|types}","create_relationship":"http://localhost:7474/db/data/node/4315/relationships","data":{"test":true,"uuid":"5df3bf40-88aa-11e3-9992-d7608d571cea"}}],[{"extensions":{},"paged_traverse":"http://localhost:7474/db/data/node/4316/paged/traverse/{returnType}{?pageSize,leaseTime}","labels":"http://localhost:7474/db/data/node/4316/labels","outgoing_relationships":"http://localhost:7474/db/data/node/4316/relationships/out","traverse":"http://localhost:7474/db/data/node/4316/traverse/{returnType}","all_typed_relationships":"http://localhost:7474/db/data/node/4316/relationships/all/{-list|&|types}","property":"http://localhost:7474/db/data/node/4316/properties/{key}","all_relationships":"http://localhost:7474/db/data/node/4316/relationships/all","self":"http://localhost:7474/db/data/node/4316","properties":"http://localhost:7474/db/data/node/4316/properties","outgoing_typed_relationships":"http://localhost:7474/db/data/node/4316/relationships/out/{-list|&|types}","incoming_relationships":"http://localhost:7474/db/data/node/4316/relationships/in","incoming_typed_relationships":"http://localhost:7474/db/data/node/4316/relationships/in/{-list|&|types}","create_relationship":"http://localhost:7474/db/data/node/4316/relationships","data":{"test":true,"uuid":"64217920-88aa-11e3-9992-d7608d571cea"}}]]}

Parsing a cypher request

var Neo4jStreamDeserializer = require('neo4j-stream-deserializer');
var request                 = require('request');

request.post({
    url     : 'http://localhost:7474/db/data/cypher',
    form    : { query: 'match (n:User) return n' },
    headers : { "X-Stream": true, "Accept": "application/json" }
  })
  .pipe(new Neo4jStreamDeserializer())
  .on('data', function (result){
    console.log(result.user);
  })
  .on('end', function() {
    console.log('all done');
  })
;

Reading from a file

var should                  = require("should");
var Neo4jStreamDeserializer = require('../index');
var fs                      = require('fs');

describe('Neo4j deserializer', function () {

  it('should be able to parse a file', function (done) {
    var results = 0;
    fs
      .createReadStream('./test/mock/neo4j_response.json')
      .pipe(new Neo4jStreamDeserializer())
      .on('data', function (result){
        results++;
        result.n.test.should.be.ok;
      })
      .on('end', function() {
        results.should.eql(10);
        done();
      })
    ;
  });
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.