diff --git a/README.md b/README.md
index 1db4938e..0d718f49 100644
--- a/README.md
+++ b/README.md
@@ -138,7 +138,7 @@ db.get('foo', function (err, value) {
-### `db.open([callback])`
+### `db.open([options][, callback])`
Opens the underlying store. In general you should never need to call this method directly as it's automatically called by levelup().
diff --git a/lib/levelup.js b/lib/levelup.js
index 8e64c82a..a6853913 100644
--- a/lib/levelup.js
+++ b/lib/levelup.js
@@ -61,15 +61,24 @@ LevelUP.prototype.emit = EventEmitter.prototype.emit
LevelUP.prototype.once = EventEmitter.prototype.once
inherits(LevelUP, EventEmitter)
-LevelUP.prototype.open = function (callback) {
+LevelUP.prototype.open = function (opts, callback) {
var self = this
var promise
+ if (typeof opts === 'function') {
+ callback = opts
+ opts = null
+ }
+
if (!callback) {
callback = promisify()
promise = callback.promise
}
+ if (!opts) {
+ opts = this.options
+ }
+
if (this.isOpen()) {
process.nextTick(callback, null, self)
return promise
@@ -82,7 +91,7 @@ LevelUP.prototype.open = function (callback) {
this.emit('opening')
- this.db.open(this.options, function (err) {
+ this.db.open(opts, function (err) {
if (err) {
return callback(new OpenError(err))
}
diff --git a/test/init-test.js b/test/init-test.js
index 9fff7fe4..2967263e 100644
--- a/test/init-test.js
+++ b/test/init-test.js
@@ -58,5 +58,24 @@ buster.testCase('Init & open()', {
return done()
}
throw new Error('did not throw')
+ },
+
+ 'support open options': function (done) {
+ var down = memdown()
+
+ levelup(down, (err, up) => {
+ refute(err, 'no error')
+
+ up.close(() => {
+ down.open = (opts) => {
+ assert.equals(opts.foo, 'bar')
+ done()
+ }
+
+ up.open({
+ foo: 'bar'
+ })
+ })
+ })
}
})