diff --git a/API.md b/API.md index 64d0b66..d94dd0a 100644 --- a/API.md +++ b/API.md @@ -21,10 +21,10 @@ const db = await orbitdb.keyvalue('profile') ``` **Public OrbitDB Instance Methods** -- [orbitdb.create(name, type, [options])]() -- [orbitdb.open(name|address, [options])]() +- [orbitdb.create(name, type, [options])](#orbitdbcreatename-type-options) +- [orbitdb.open(name|address, [options])](#orbitdbopenaddress-options) +- [orbitdb.disconnect()](#orbitdbdisconnect) - [orbitdb.stop()](#orbitdbstop) -- [orbitdb.disconnect()](orbitdbdisconnect) - [orbitdb.keyvalue(name|address)](#orbitdbkeyvaluenameaddress) - [kv.put(key, value)](#putkey-value) - [kv.set(key, value)](#setkey-value) @@ -105,14 +105,20 @@ Returns a `Promise` that resolves to [a database instance](#store). `address` (s - `type` (string): A supported database type (i.e. `eventlog` or [an added custom type](https://github.com/orbitdb/orbit-db#custom-store-types)). Required if create is set to `true`. Otherwise it's used to validate the manifest. - `overwrite` (boolean): Overwrite an existing database (Default: `false`) +### orbitdb.disconnect() + +Close databases, connections, pubsub and reset orbitdb state. + +```javascript +await orbitdb.disconnect() +``` + ### orbitdb.stop() - Stop OrbitDB, close databases and disconnect the databases from the network. - - ```javascript - orbitdb.stop() - ``` -### orbitdb.disconnect() +Alias for `orbitdb.disconnect()` +```javascript +await orbitdb.stop() +``` ### orbitdb.keyvalue(name|address) > Creates and opens a keyvalue database diff --git a/README.md b/README.md index 2c57f4a..3d3b593 100644 --- a/README.md +++ b/README.md @@ -140,55 +140,57 @@ After creating an `OrbitDB` instance , you can access the different data stores. *For further details, see usage for [kvstore](https://github.com/orbitdb/orbit-db-kvstore#usage), [eventlog](https://github.com/orbitdb/orbit-db-eventstore#usage), [feed](https://github.com/orbitdb/orbit-db-feedstore#usage), [docstore](https://github.com/orbitdb/orbit-db-docstore#usage) and [counter](https://github.com/orbitdb/orbit-db-counterstore#usage).* -- **Public OrbitDB Instance Methods** - - [orbitdb.keyvalue(name|address)](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdbkeyvaluenameaddress) - - [kv.put(key, value)](https://github.com/orbitdb/orbit-db/blob/master/API.md#putkey-value) - - [kv.set(key, value)](https://github.com/orbitdb/orbit-db/blob/master/API.md#setkey-value) - - [kv.get(key)](https://github.com/orbitdb/orbit-db/blob/master/API.md#getKey) - - [orbitdb.log(name|address)](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdblognameaddress) - - [log.add(event)](https://github.com/orbitdb/orbit-db/blob/master/API.md#addevent) - - [log.get(hash)](https://github.com/orbitdb/orbit-db/blob/master/API.md#gethash) - - [log.iterator([options])](https://github.com/orbitdb/orbit-db/blob/master/API.md#iteratoroptions) - - [orbitdb.feed(name|address)](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdbfeednameaddress) - - [feed.add(data)](https://github.com/orbitdb/orbit-db/blob/master/API.md#adddata) - - [feed.get(hash)](https://github.com/orbitdb/orbit-db/blob/master/API.md#gethash-1) - - [feed.remove(hash)](https://github.com/orbitdb/orbit-db/blob/master/API.md#removehash) - - [feed.iterator([options])](https://github.com/orbitdb/orbit-db/blob/master/API.md#iteratoroptions-1) - - [orbitdb.docs(name|address, options)](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdbdocsnameaddress-options) - - [docs.put(doc)](https://github.com/orbitdb/orbit-db/blob/master/API.md#putdoc) - - [docs.get(hash)](https://github.com/orbitdb/orbit-db/blob/master/API.md#getkey-1) - - [docs.query(mapper)](https://github.com/orbitdb/orbit-db/blob/master/API.md#querymapper) - - [del(key)](https://github.com/orbitdb/orbit-db/blob/master/API.md#delkey) - - [orbitdb.counter(name|address)](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdbcounternameaddress) - - [counter.value](https://github.com/orbitdb/orbit-db/blob/master/API.md#value) - - [counter.inc([value])](https://github.com/orbitdb/orbit-db/blob/master/API.md#incvalue) - - [orbitdb.create(name|address, type, [options])]() - - [orbitdb.open(name|address, [options])]() - - [orbitdb.stop()](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdbstop) - - [orbitdb.disconnect()](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdbdisconnect) -- **Static Properties** - - [OrbitDB.databaseTypes](https://github.com/orbitdb/orbit-db/blob/master/API.md#databasetypes) -- **Static Methods** - - [OrbitDB.isValidType(type)](https://github.com/orbitdb/orbit-db/blob/master/API.md#isvalidtypetype) - - [OrbitDB.addDatabaseType(type, store)](https://github.com/orbitdb/orbit-db/blob/master/API.md#adddatabasetypetype-store) - - [OrbitDB.getDatabaseTypes()](https://github.com/orbitdb/orbit-db/blob/master/API.md#getdatabasetypes) - - [OrbitDB.isValidAddress(address)](https://github.com/orbitdb/orbit-db/blob/master/API.md#isvalidaddressaddress) - - [OrbitDB.parseAddress(address)](https://github.com/orbitdb/orbit-db/blob/master/API.md#parseaddressaddress) +**Public OrbitDB Instance Methods** +- [orbitdb.create(name|address, type, [options])](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdbcreatename-type-options) +- [orbitdb.open(name|address, [options])](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdbopenaddress-options) +- [orbitdb.disconnect()](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdbdisconnect) +- [orbitdb.stop()](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdbstop) +- [orbitdb.keyvalue(name|address)](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdbkeyvaluenameaddress) + - [kv.put(key, value)](https://github.com/orbitdb/orbit-db/blob/master/API.md#putkey-value) + - [kv.set(key, value)](https://github.com/orbitdb/orbit-db/blob/master/API.md#setkey-value) + - [kv.get(key)](https://github.com/orbitdb/orbit-db/blob/master/API.md#getKey) +- [orbitdb.log(name|address)](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdblognameaddress) + - [log.add(event)](https://github.com/orbitdb/orbit-db/blob/master/API.md#addevent) + - [log.get(hash)](https://github.com/orbitdb/orbit-db/blob/master/API.md#gethash) + - [log.iterator([options])](https://github.com/orbitdb/orbit-db/blob/master/API.md#iteratoroptions) +- [orbitdb.feed(name|address)](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdbfeednameaddress) + - [feed.add(data)](https://github.com/orbitdb/orbit-db/blob/master/API.md#adddata) + - [feed.get(hash)](https://github.com/orbitdb/orbit-db/blob/master/API.md#gethash-1) + - [feed.remove(hash)](https://github.com/orbitdb/orbit-db/blob/master/API.md#removehash) + - [feed.iterator([options])](https://github.com/orbitdb/orbit-db/blob/master/API.md#iteratoroptions-1) +- [orbitdb.docs(name|address, options)](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdbdocsnameaddress-options) + - [docs.put(doc)](https://github.com/orbitdb/orbit-db/blob/master/API.md#putdoc) + - [docs.get(hash)](https://github.com/orbitdb/orbit-db/blob/master/API.md#getkey-1) + - [docs.query(mapper)](https://github.com/orbitdb/orbit-db/blob/master/API.md#querymapper) + - [del(key)](https://github.com/orbitdb/orbit-db/blob/master/API.md#delkey) +- [orbitdb.counter(name|address)](https://github.com/orbitdb/orbit-db/blob/master/API.md#orbitdbcounternameaddress) + - [counter.value](https://github.com/orbitdb/orbit-db/blob/master/API.md#value) + - [counter.inc([value])](https://github.com/orbitdb/orbit-db/blob/master/API.md#incvalue) -- [Store API](https://github.com/orbitdb/orbit-db/blob/master/API.md#store) - - [load()](https://github.com/orbitdb/orbit-db/blob/master/API.md#storeload) - - [close()](https://github.com/orbitdb/orbit-db/blob/master/API.md#storeclose) - - [drop()](https://github.com/orbitdb/orbit-db/blob/master/API.md#storedrop) - - [key](https://github.com/orbitdb/orbit-db/blob/master/API.md#storekey) - - [type](https://github.com/orbitdb/orbit-db/blob/master/API.md#storetype) -- [Store Events](https://github.com/orbitdb/orbit-db/blob/master/API.md#storeevents) - - [replicated](https://github.com/orbitdb/orbit-db/blob/master/API.md#replicated) - - [replicate](https://github.com/orbitdb/orbit-db/blob/master/API.md#replicate) - - [replicate.progress](https://github.com/orbitdb/orbit-db/blob/master/API.md#replicateprogress) - - [load](https://github.com/orbitdb/orbit-db/blob/master/API.md#load-1) - - [load.progress](https://github.com/orbitdb/orbit-db/blob/master/API.md#loadprogress) - - [ready](https://github.com/orbitdb/orbit-db/blob/master/API.md#ready) - - [write](https://github.com/orbitdb/orbit-db/blob/master/API.md#write) +**Static Properties** +- [OrbitDB.databaseTypes](https://github.com/orbitdb/orbit-db/blob/master/API.md#databasetypes) + +**Static Methods** +- [OrbitDB.isValidType(type)](https://github.com/orbitdb/orbit-db/blob/master/API.md#isvalidtypetype) +- [OrbitDB.addDatabaseType(type, store)](https://github.com/orbitdb/orbit-db/blob/master/API.md#adddatabasetypetype-store) +- [OrbitDB.getDatabaseTypes()](https://github.com/orbitdb/orbit-db/blob/master/API.md#getdatabasetypes) +- [OrbitDB.isValidAddress(address)](https://github.com/orbitdb/orbit-db/blob/master/API.md#isvalidaddressaddress) +- [OrbitDB.parseAddress(address)](https://github.com/orbitdb/orbit-db/blob/master/API.md#parseaddressaddress) + +**[Store API](https://github.com/orbitdb/orbit-db/blob/master/API.md#store)** +- [load()](https://github.com/orbitdb/orbit-db/blob/master/API.md#storeload) +- [close()](https://github.com/orbitdb/orbit-db/blob/master/API.md#storeclose) +- [drop()](https://github.com/orbitdb/orbit-db/blob/master/API.md#storedrop) +- [key](https://github.com/orbitdb/orbit-db/blob/master/API.md#storekey) +- [type](https://github.com/orbitdb/orbit-db/blob/master/API.md#storetype) +**[Store Events](https://github.com/orbitdb/orbit-db/blob/master/API.md#storeevents)** +- [replicated](https://github.com/orbitdb/orbit-db/blob/master/API.md#replicated) +- [replicate](https://github.com/orbitdb/orbit-db/blob/master/API.md#replicate) +- [replicate.progress](https://github.com/orbitdb/orbit-db/blob/master/API.md#replicateprogress) +- [load](https://github.com/orbitdb/orbit-db/blob/master/API.md#load-1) +- [load.progress](https://github.com/orbitdb/orbit-db/blob/master/API.md#loadprogress) +- [ready](https://github.com/orbitdb/orbit-db/blob/master/API.md#ready) +- [write](https://github.com/orbitdb/orbit-db/blob/master/API.md#write) ### Custom Store Types