DatabaseController

DatabaseController

Controller for CouchDB (remote) and PouchDB (local) databases

Constructor

new DatabaseController()

Source:

Extends

  • Map

Methods

fetchDoc(config) → {Object|Error}

Source:

Fetches a document from a database

Parameters:
Name Type Description
config Object

configuration object

Properties
Name Type Attributes Default Description
db String

database name

id String

document _id

options Object <optional>
{}

PouchDB config object

Returns:
Type
Object | Error

init(config)

Source:

Initializes a new DatabaseController

Parameters:
Name Type Description
config Object

configuration object

Properties
Name Type Attributes Default Description
server Esdi

Esdi server instance

dbAddress String <optional>
'local'

address of remote database, or local for local database

dbPort String <optional>
5984

port of remote database

dbNamespace String <optional>
'esdi_'

namespace prefix for database names

loadDb(name, dbAddressopt, portopt) → {Object}

Source:

Loads and syncs with a database

Parameters:
Name Type Attributes Default Description
name String

database name

dbAddress String <optional>
'local'

remote database address, or local for local database

port Number <optional>
5984

remote database port

Returns:
Type
Object

start()

Source:

Starts the DatabaseController

Listens to Events:

stop()

Source:

Stops the DatabaseController

Listens to Events:

stopSyncing()

Source:

Stops syncing all databases

updateDoc(config)

Source:

Updates or creates a document in a database

Parameters:
Name Type Description
config Object

configuration object

Properties
Name Type Description
db String

database name

id String

document _id

payload Object

payload for document