ClientDatabaseBackend

ClientDatabaseBackend

The client-side database backend implementation which handles Document modification operations.

Constructor

new ClientDatabaseBackend()

Implements:

Extends

Methods

(async, protected) _createDocuments() → {Promise.<Array.<Document>>}

Overrides:
Implements:

Create primary Document instances

Returns:
Type
Promise.<Array.<Document>>

(async, protected) _createEmbeddedDocuments() → {Promise.<Array.<Document>>}

Overrides:
Implements:

Create embedded Document instances

Returns:
Type
Promise.<Array.<Document>>

(async, protected) _deleteDocuments() → {Promise.<Array.<Document>>}

Overrides:
Implements:

Delete primary Document instances

Returns:
Type
Promise.<Array.<Document>>

(async, protected) _deleteEmbeddedDocuments() → {Promise.<Array.<Document>>}

Overrides:
Implements:

Delete embedded Document instances

Returns:
Type
Promise.<Array.<Document>>

(async, protected) _getDocuments()

Overrides:
Implements:

Get primary Document instances

(async, protected) _getEmbeddedDocuments()

Overrides:
Implements:

Get embedded Document instances

(protected) _getLogger() → {Logger|Console}

Inherited From:
Implements:

Provide the Logger implementation that should be used for database operations

Returns:
Type
Logger | Console

_handleCreateDocuments(response) → {Array.<Document>}

Handle a SocketResponse from the server when one or multiple documents were created

Parameters:
Name Type Description
response SocketResponse

The provided Socket response

Properties
Name Type Attributes Description
request SocketRequest <optional>

The initial socket request

result Array.<object> <optional>

An Array of created data objects

userId string <optional>

The id of the requesting User

Returns:

An Array of created Document instances

Type
Array.<Document>

_handleCreateEmbeddedDocuments(response) → {Array.<Document>}

Handle a SocketResponse from the server when one or multiple documents were created

Parameters:
Name Type Description
response SocketResponse

The provided Socket response

Properties
Name Type Attributes Description
request SocketRequest <optional>

The initial socket request

result Array.<object> <optional>

An Array of created data objects

userId string <optional>

The id of the requesting User

Returns:

An Array of created Document instances

Type
Array.<Document>

_handleDeleteDocuments(response) → {Array.<Document>}

Handle a SocketResponse from the server where Documents are deleted.

Parameters:
Name Type Description
response SocketResponse

The provided Socket response

Properties
Name Type Attributes Description
request SocketRequest <optional>

The initial socket request

result Array.<string> <optional>

An Array of deleted Document ids

userId string <optional>

The id of the requesting User

Returns:

An Array of deleted Document instances

Type
Array.<Document>

_handleDeleteEmbeddedDocuments(response) → {Array.<Document>}

Handle a SocketResponse from the server when embedded Documents are deleted from a parent Document.

Parameters:
Name Type Description
response SocketResponse

The provided Socket response

Properties
Name Type Attributes Description
request SocketRequest <optional>

The initial socket request

result Array.<string> <optional>

An Array of deleted Document ids

userId string <optional>

The id of the requesting User

Returns:

An Array of deleted Document instances

Type
Array.<Document>

_handleUpdateDocuments(response) → {Array.<Document>}

Handle a SocketResponse from the server when one or multiple documents were updated

Parameters:
Name Type Description
response SocketResponse

The provided Socket response

Properties
Name Type Attributes Description
request SocketRequest <optional>

The initial socket request

result Array.<object> <optional>

An Array of incremental data objects

userId string <optional>

The id of the requesting User

Returns:

An Array of updated Document instances

Type
Array.<Document>

_handleUpdateEmbeddedDocuments(response) → {Array.<Document>}

Handle a SocketResponse from the server when embedded Documents are updated in a parent Document.

Parameters:
Name Type Description
response SocketResponse

The provided Socket response

Properties
Name Type Attributes Description
request SocketRequest <optional>

The initial socket request

result Array.<object> <optional>

An Array of incremental data objects

userId string <optional>

The id of the requesting User

Returns:

An Array of updated Document instances

Type
Array.<Document>

(protected) _logError() → {string}

Inherited From:
Implements:

Construct a standardized error message given the context of an attempted operation

Returns:
Type
string

(protected) _logOperation(action, type, documents, levelopt, parentopt, packopt)

Inherited From:
Implements:

Log a database operation for an embedded document, capturing the action taken and relevant IDs

Parameters:
Name Type Attributes Default Description
action string

The action performed

type string

The document type

documents Array.<abstract.Document>

The documents modified

level string <optional>
info

The logging level

parent abstract.Document <optional>

A parent document

pack string <optional>

A compendium pack within which the operation occurred

(async, protected) _updateDocuments() → {Promise.<Array.<Document>>}

Overrides:
Implements:

Update primary Document instances

Returns:
Type
Promise.<Array.<Document>>

(async, protected) _updateEmbeddedDocuments() → {Promise.<Array.<Document>>}

Overrides:
Implements:

Update embedded Document instances

Returns:
Type
Promise.<Array.<Document>>

activateSocketListeners(socket)

Activate the Socket event listeners used to receive responses from events which modify database documents

Parameters:
Name Type Description
socket Socket

The active game socket

(async) create(documentClass, request, user) → {Array.<Document>}

Inherited From:
Implements:

Perform document creation operations

Parameters:
Name Type Description
documentClass function

The Document definition

request object

The requested operation

user BaseUser

The requesting User

Returns:

The created Document instances

Type
Array.<Document>

(async) delete(documentClass, request, user) → {Array.<Document>}

Inherited From:
Implements:

Perform document deletion operations

Parameters:
Name Type Description
documentClass function

The Document definition

request object

The requested operation

user BaseUser

The requesting User

Returns:

The deleted Document instances

Type
Array.<Document>

(async) get(documentClass, request, user) → {Array.<Document>}

Inherited From:
Implements:

Retrieve Documents based on provided query parameters

Parameters:
Name Type Description
documentClass function

The Document definition

request object

The requested operation

user BaseUser

The requesting User

Returns:

The created Document instances

Type
Array.<Document>

(protected) getCompendiumScopes() → {Array.<string>}

Overrides:
Implements:

Describe the scopes which are suitable as the namespace for a flag key

Returns:
Type
Array.<string>

(protected) getFlagScopes() → {Array.<string>}

Overrides:
Implements:

Describe the scopes which are suitable as the namespace for a flag key

Returns:
Type
Array.<string>

(async) update(documentClass, request, user) → {Array.<Document>}

Inherited From:
Implements:

Perform document update operations

Parameters:
Name Type Description
documentClass function

The Document definition

request object

The requested operation

user BaseUser

The requesting User

Returns:

The updated Document instances

Type
Array.<Document>