Skip to content

Commit

Permalink
various additions for multilevel compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
staticskies committed Oct 25, 2015
1 parent a59758a commit 32c5b6e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/levelgraph.js
Expand Up @@ -110,6 +110,18 @@ module.exports = function levelgraph(leveldb, options) {
return db;
};

// patch variables in a query
function patchQuery(query) {
query.forEach(function(e) {
utilities.defs.spo.forEach(function(key) {
if (typeof e[key] === 'object' &&
e[key].constructor !== Variable) {
e[key] = new Variable(e[key].name);
}
});
});
}

searchStream = function(db, options) {
options = extend({ joinAlgorithm: 'sort' }, options);

Expand All @@ -119,6 +131,7 @@ searchStream = function(db, options) {
var that = this
, result = new PassThrough({ objectMode: true });

patchQuery(query);

options = extend(joinDefaults, options);

Expand Down Expand Up @@ -192,7 +205,8 @@ doAction = function(action, leveldb) {

doActionStream = function(type, leveldb) {

if (!leveldb.createWriteStream) {
// also check leveldb.isClient for multilevel compatibility
if (!leveldb.createWriteStream || leveldb.isClient) {
leveldb = levelWriteStream(leveldb);
}

Expand Down

0 comments on commit 32c5b6e

Please sign in to comment.