Skip to content

Commit 9a2e6f6

Browse files
author
Benjamin Forster
committed
add namespacing to blank nodes on import
1 parent 380d27d commit 9a2e6f6

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

lib/utils.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ function collect (stream, cb) {
1717
stream.once('end', cb.bind(null, null, res))
1818
}
1919

20+
function namespaceBlankVariables (triple) {
21+
Object.keys(triple).forEach((key) => {
22+
if (triple[key].startsWith && triple[key].startsWith('_:')) {
23+
triple[key] = triple[key].replace(/^_:/, 'hypergraph:')
24+
}
25+
})
26+
return triple
27+
}
28+
2029
function filterTriple (triple) {
2130
const filtered = {}
2231
defs.spo.forEach((key) => {
@@ -58,7 +67,7 @@ function genKeys (triple) {
5867
function generateBatch (triple, action) {
5968
if (!action) action = 'put'
6069
var data = (action === 'put')
61-
? JSON.stringify(triple)
70+
? JSON.stringify(namespaceBlankVariables(triple))
6271
: null
6372
return genKeys(triple).map(key => ({
6473
type: 'put', // no delete in hyperdb so just puting nulls

0 commit comments

Comments
 (0)