diff --git a/src/OrbitDB.js b/src/OrbitDB.js index bfc8d44..16bdf96 100644 --- a/src/OrbitDB.js +++ b/src/OrbitDB.js @@ -202,7 +202,7 @@ class OrbitDB { // accessController.add('admin', this.key.getPublic('hex')) // } // Add keys that can write to the database - if (options && options.write) { + if (options && options.write && options.write.length > 0) { options.write.forEach(e => accessController.add('write', e)) } else { // Default is to add ourselves as the admin of the database diff --git a/test/create-open.test.js b/test/create-open.test.js index b4f7906..1054441 100644 --- a/test/create-open.test.js +++ b/test/create-open.test.js @@ -218,6 +218,12 @@ describe('orbit-db - Create & Open', function() { assert.equal(db.address.toString().indexOf('abc'), 56) }) + it('opens a database and adds the creator as the only writer', async () => { + db = await orbitdb.open('abc', { create: true, type: 'feed', overwrite: true, write: [] }) + assert.equal(db.access.write.length, 1) + assert.equal(db.access.write[0], db.key.getPublic('hex')) + }) + it('doesn\'t open a database if we don\'t have it locally', async () => { const address = new OrbitDBAddress(db.address.root.slice(0, -1) + 'A', 'non-existent') return new Promise((resolve, reject) => {