@webwallet/graphstore
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -20,3 +20,3 @@ 'use strict' | ||
let type = query.txmode || options.txmode | ||
let type = options.txmode || query.txmode | ||
let transaction = options.transaction || new Transaction(driver, type) | ||
@@ -23,0 +23,0 @@ let result |
@@ -9,3 +9,4 @@ 'use strict' | ||
with * unwind params.outputs as thisOutput | ||
optional match (countspace)-[:Addresses]->(address:Address {id: thisOutput.address}) | ||
optional match (countspace)-[:Addresses]->(address:Address) | ||
where address.id = thisOutput.address set address.writeLock = timestamp() | ||
with *, thisOutput.sources + [''] as pointers | ||
@@ -17,15 +18,18 @@ unwind [pointer in pointers | split(pointer, '::')] as pointer | ||
with countspace, params, collect(distinct source) as sources, | ||
reduce(pointers = [], pointer in [output in params.outputs | | ||
output.sources] | pointers + pointer) as reducedPointers, | ||
collect(distinct source.id + '::' + output.id) as pointers | ||
create (transaction:Transaction {id: $id, time: timestamp()}) | ||
foreach (_ in case when size(params.sources)=size(pointers) then [1] else [] end | | ||
foreach (_ in case when size(pointers)=size(reducedPointers) then [1] else [] end | | ||
foreach (input in params.inputs | merge (transaction)-[:Inputs]->(:IOU {id: input.hash})) | ||
foreach (output in params.outputs | | ||
merge (countspace)-[:Addresses]->(address:Address {id: output.address}) | ||
merge (address)-[:Outputs {id: toInteger(output.index)}]->(transaction) | ||
foreach (pointer in [source in output.sources | split(source, '::')] | | ||
foreach (funding in [source in sources where pointer[0] = source.id] | | ||
merge (transaction)-[:Sources {id: toInteger(pointer[1])}]->(funding)) | ||
) | ||
merge (transaction)-[:Sources {id: toInteger(pointer[1])}]->(funding))) | ||
) | ||
foreach (output in params.outputs | | ||
merge (countspace)-[:Addresses]->(address:Address {id: output.address}) | ||
merge (address)-[:Outputs {id: toInteger(output.index)}]->(transaction) | ||
) | ||
) | ||
@@ -43,4 +47,5 @@ | ||
module.exports = { | ||
txmode: 'write', | ||
string: uglifyQueryString(query), | ||
parser(result) { | ||
parser: (result) =>{ | ||
return { | ||
@@ -47,0 +52,0 @@ id: result.get('id'), |
{ | ||
"name": "@webwallet/graphstore", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Graph database queries and connection handling.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
11929
16
238