Namespace: OrbitDB

OrbitDB~OrbitDB

The instance returned by module:OrbitDB.

Source:

Methods

(async) open(address, params) → {module:Database}

Open a database or create one if it does not already exist.

By default, OrbitDB will create a database of type DefaultDatabaseType:

const mydb = await orbitdb.open('mydb')

To create a database of a different type, specify the type param:

const mydb = await orbitdb.open('mydb', {type: 'documents'})

The type must be listed in databaseTypes or an error is thrown. To open an existing database, pass its address to the open function:

const existingDB = await orbitdb.open(dbAddress)

The address of a newly created database can be retrieved using db.address.

Parameters:
Name Type Description
address string

The address of an existing database to open, or the name of a new database.

params Object

One or more database configuration parameters.

Properties
Name Type Attributes Default Description
type string <optional>
events

The database's type.

meta * <optional>
{}

The database's metadata. Only applies when creating a database and is not used when opening an existing database.

sync boolean <optional>
true

If true, sync databases automatically. Otherwise, false.

Database module:Database <optional>
Events

A Database-compatible module.

AccessController module:AccessControllers <optional>
IPFSAccessController

An AccessController-compatible module.

headsStorage module:Storage <optional>
ComposedStorage

A compatible storage instance for storing log heads. Defaults to ComposedStorage(LRUStorage, LevelStorage).

entryStorage module:Storage <optional>
ComposedStorage

A compatible storage instance for storing log entries. Defaults to ComposedStorage(LRUStorage, IPFSBlockStorage).

indexStorage module:Storage <optional>
ComposedStorage

A compatible storage instance for storing an " index of log entries. Defaults to ComposedStorage(LRUStorage, LevelStorage).

referencesCount number <optional>

The number of references to use for Log entries.

Source:
Throws:

"Unsupported database type" if the type specified is not in the list of known databaseTypes.

Returns:

A database instance.

Type
module:Database

(async) stop()

Stops OrbitDB, closing the underlying keystore and manifest store.

Source: