Namespace: Database

Databases~Database

The instance returned by module:Database~Database.

Source:

Members

access

The access controller instance of the database.

Source:

address

The address of the database.

Source:

events

Event emitter that emits Database changes. See Events section for details.

Source:

log

The underlying operations log of the database.

Source:

name

The name of the database.

Source:

peers

Set of currently connected peers for this Database instance.

Source:

sync

A sync instance of the database.

Source:

Methods

(async) addOperation(op) → {string}

Adds an operation to the oplog.

Parameters:
Name Type Description
op *

Some operation to add to the oplog.

Source:
Returns:

The hash of the operation.

Type
string

(async) close()

Closes the database, stopping sync and closing the oplog.

Source:

(async) drop()

Drops the database, clearing the oplog.

Source:

Events

close

Event fired when a close occurs.

Source:
Example
database.events.on('close', () => ...)

drop

Event fired when a drop occurs.

Source:
Example
database.events.on('drop', () => ...)

join

Event fired when when a peer has connected to the database.

Parameters:
Name Type Description
peerId PeerID

PeerID of the peer who connected

heads Array.<Entry>

An array of Log entries

Source:
Example
database.events.on('join', (peerID, heads) => ...)

leave

Event fired when a peer has disconnected from the database.

Parameters:
Name Type Description
peerId PeerID

PeerID of the peer who disconnected

Source:
Example
database.events.on('leave', (peerID) => ...)

update

Event fired when an update occurs.

Parameters:
Name Type Description
entry module:Entry

An entry.

Source:
Example
database.events.on('update', (entry) => ...)