docs: add api description for orbitdb.open

This commit is contained in:
Kia Rahimian 2018-07-13 15:14:48 -04:00
parent ca78ae7a55
commit 96fe2a9c6a

14
API.md
View File

@ -291,7 +291,19 @@ const db = await orbitdb.create('user.posts', 'eventlog', {
}) })
// db created & opened // db created & opened
``` ```
### orbitdb.open(name|address, [options]) ### orbitdb.open(address, [options])
> Opens an OrbitDB database.
Convienance methods are available when opening/creating any of the default OrbitDB database types (i.e. `orbitdb.feed(address, options)` instead of `orbitdb.open(address, { type: 'feed', ... })`)
Returns a `Promise` that resolves to [a database instance](#store). `address` (string) should be a valid OrbitDB address. If a database name is provided instead, it will check `options.create` to determine if it should create the database. `options` is an object with any of the following properties:
- `localOnly` (boolean): If set to `true`, will throw an error if the database can't be found locally. (Default: `false`)
- `directory` (string): The directory where data will be stored (Default: uses directory option passed to OrbitDB constructor or `./orbitdb` if none was provided).
- `create` (boolean): Whether to create the database if a valid OrbitDB address is not provided. (Default: `false`)
- `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.stop() ### orbitdb.stop()
Stop OrbitDB, close databases and disconnect the databases from the network. Stop OrbitDB, close databases and disconnect the databases from the network.