diff --git a/nut.js b/nut.js index 07f0fc7..85b8839 100644 --- a/nut.js +++ b/nut.js @@ -61,6 +61,7 @@ module.exports = function (db, precodec, codec, compare) { } return { + db: db, apply: function (ops, opts, cb) { //apply prehooks here. for(var i = 0; i < ops.length; i++) { diff --git a/shell.js b/shell.js index daad9f1..9077cb1 100644 --- a/shell.js +++ b/shell.js @@ -24,6 +24,15 @@ var sublevel = module.exports = function (nut, prefix, createStream, options) { emitter.version = version + // set the leveldown instance + emitter.db = nut.db.db ? nut.db.db : nut.db + // work around DeferredLevelDown limitations + if (typeof nut.db.once === 'function') { + nut.db.once('open', function onOpen() { + emitter.db = nut.db.db ? nut.db.db : nut.db + }) + } + emitter.methods = {} prefix = prefix || []