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

Alias

foundry.data.ClientDatabaseBackend

Hierarchy (view full)

Properties

#flagScopes: string[]

A cached array of valid flag scopes which can be read and written.

Methods

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

    Returns any[]

  • Parameters

    • level: any
    • message: any

    Returns void

  • Retrieve Documents based on provided query parameters. It recommended to use CompendiumCollection#getDocuments or CompendiumCollection#getIndex rather than calling this method directly.

    Parameters

    • documentClass: typeof Document

      The Document class definition

    • operation: DatabaseGetOperation

      Parameters of the get operation

    • Optional user: BaseUser

      The requesting User

    Returns Promise<object[] | Document[]>

    An array of retrieved Document instances or index objects

  • Protected

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

    Parameters

    • action: string

      The action performed

    • type: string

      The document type

    • documents: Document[]

      The documents modified

    • Optional __namedParameters: string = {}

    Returns void

  • Protected

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

    Parameters

    • user: any
    • action: any
    • subject: any
    • __namedParameters: {
          parent: any;
          pack: any;
      } = {}
      • parent: any
      • pack: any

    Returns string

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

    Parameters

    • response: DocumentSocketResponse

      A document modification socket response

    Returns Promise<ClientDocument[]>

    An Array of created Document instances

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

    Parameters

    • response: DocumentSocketResponse

      A document modification socket response

    Returns Promise<ClientDocument[]>

    An Array of updated Document instances

  • Handle a SocketResponse from the server where Documents are deleted.

    Parameters

    • response: DocumentSocketResponse

      A document modification socket response

    Returns Promise<ClientDocument[]>

    An Array of deleted Document instances

  • Handle a socket response broadcast back from the server.

    Parameters

    • response: DocumentSocketResponse

      A document modification socket response

    Returns void

  • Common database operation configuration steps.

    Parameters

    • operation: DatabaseOperation

      The requested operation

    Returns Promise<void>

  • Determine a string suffix for a log message based on the parent and/or compendium context.

    Parameters

    Returns string

  • Perform a standardized pre-creation workflow for all Document types. This workflow mutates the operation data array.

    Parameters

    Returns Promise<void>

  • Perform a standardized pre-update workflow for all Document types. This workflow mutates the operation updates array.

    Parameters

    Returns Promise<void>

  • Perform a standardized pre-delete workflow for all Document types. This workflow mutates the operation ids array.

    Parameters

    Returns Promise<void>

  • Obtain the document collection for a given Document class and database operation.

    Parameters

    • documentClass: typeof Document

      The Document class being operated upon

    • operation: {
          parent: any;
          pack: string;
      }

      The database operation being performed

      • parent: any

        A parent Document, if applicable

      • pack: string

        A compendium pack identifier, if applicable

    Returns any

    The relevant collection instance for this request

  • Dispatch a document modification socket request to the server.

    Parameters

    Returns DocumentSocketResponse

  • Ensure the given list of documents is loaded into the compendium collection so that they can be retrieved by subsequent operations.

    Parameters

    • collection: Collection

      The candidate collection.

    • documents: string[] | object[]

      An array of update deltas, or IDs, depending on the operation.

    Returns Promise<void>

  • Augment a database operation with alterations needed to support ActorDelta and TokenDocuments.

    Parameters

    Returns void

  • Retrieve a Document's Token ancestor, if it exists.

    Parameters

    • parent: Document

      The parent Document

    Returns any

    The Token ancestor, or null

  • Build a CRUD response.

    Parameters

    • documents: ActorDelta[]

      An array of ActorDelta documents modified by a database workflow

    Returns Document[]

    The modified ActorDelta documents mapped to their synthetic Actor