@acastellon/neo4j
Advanced tools
Comparing version 1.0.0 to 1.0.1
21
neo4j.js
@@ -5,2 +5,4 @@ // | ||
// | ||
// based in Driver 1.7.x from Neo4j-driver JS official | ||
// | ||
// config parameter: | ||
@@ -42,10 +44,19 @@ // | ||
model.execute = execute; | ||
model.executeAsPromise = executeAsPromise; | ||
model.executeAsStream = executeAsStream; | ||
//model.rxexecute = rxexecute; // Reactive Session v4.0 | ||
model.executeBatch = executeBatch; | ||
const neo4jIntsToStrings = (json) => { | ||
const pluckAndModify = (isMatch, transformValue) => | ||
Object.entries(json) | ||
.filter(isMatch) | ||
.reduce((acc, [key, value]) => ({ ...acc, [key]: transformValue(value) }), {}); | ||
return Object.assign( | ||
json, | ||
pluckAndModify(([, value]) => typeof value === 'object', neo4jIntsToStrings), | ||
pluckAndModify(([, value]) => neo4j.isInt(value), value => value.toString()), | ||
); | ||
}; | ||
@@ -83,3 +94,4 @@ // | ||
result.records.forEach(v => { | ||
toReturn.push(v._fields); | ||
toReturn.push(neo4jIntsToStrings(v._fields)); | ||
//toReturn.push(v._fields); | ||
}); | ||
@@ -118,2 +130,3 @@ | ||
session.run(cypher, parameters) | ||
.then(neo4jIntsToStrings) | ||
.then( result => { | ||
@@ -154,3 +167,3 @@ resolve(result.records); | ||
//console.log(record); | ||
readableStream.push(JSON.stringify(record)); | ||
readableStream.push(JSON.stringify(neo4jIntsToStrings(record))); | ||
}, | ||
@@ -157,0 +170,0 @@ onCompleted: function() { |
{ | ||
"name": "@acastellon/neo4j", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Neo4j persistence interface", | ||
@@ -5,0 +5,0 @@ "main": "neo4.js", |
@@ -13,6 +13,6 @@ // | ||
// await testExecutionAsPromise(); | ||
// await testExecutionAsPromise_RAW(); | ||
// await testExecutionSharingConnection(); | ||
// await testExecuteAsStream(); | ||
await testExecutionAsPromise(); | ||
await testExecutionAsPromise_RAW(); | ||
await testExecutionSharingConnection(); | ||
await testExecuteAsStream(); | ||
@@ -19,0 +19,0 @@ await testBatch(); |
12681
267