Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Hierarchy

Index

Constructors

Methods

  • _getDocuments(documentClass: any, __namedParameters: Object, user: any): Promise<any>
  • Get primary Document instances

    Parameters

    • documentClass: any
    • __namedParameters: Object
    • user: any

    Returns Promise<any>

  • _createDocuments(documentClass: any, context: any, user: any): Promise<Document[]>
  • _updateDocuments(documentClass: any, context: any, user: any): Promise<Document[]>
  • _deleteDocuments(documentClass: any, context: any, user: any): Promise<Document[]>
  • activateSocketListeners(socket: Socket): void
  • Activate the Socket event listeners used to receive responses from events which modify database documents

    Parameters

    • socket: Socket

      The active game socket

    Returns void

  • getFlagScopes(): any[]
  • getCompendiumScopes(): any[]
  • get(documentClass: Function, context: any, user: BaseUser): Promise<Document[]>
  • Retrieve Documents based on provided query parameters

    Parameters

    • documentClass: Function

      The Document definition

    • context: any

      Context for the requested operation

    • user: BaseUser

    Returns Promise<Document[]>

    The created Document instances

  • create(documentClass: Function, context: any, user: BaseUser): Promise<Document[]>
  • Perform document creation operations

    Parameters

    • documentClass: Function

      The Document definition

    • context: any

      Context for the requested operation

    • user: BaseUser

    Returns Promise<Document[]>

    The created Document instances

  • update(documentClass: Function, context: any, user: BaseUser): Promise<Document[]>
  • Perform document update operations

    Parameters

    • documentClass: Function

      The Document definition

    • context: any

      Context for the requested operation

    • user: BaseUser

    Returns Promise<Document[]>

    The updated Document instances

  • delete(documentClass: Function, context: any, user: BaseUser): Promise<Document[]>
  • Perform document deletion operations

    Parameters

    • documentClass: Function

      The Document definition

    • context: any

      Context for the requested operation

    • user: BaseUser

    Returns Promise<Document[]>

    The deleted Document instances

  • _getLogger(): any
  • Provide the Logger implementation that should be used for database operations

    Returns any

  • _logOperation(action: string, type: string, documents: Document[], __namedParameters?: string): void
  • 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

    • __namedParameters: string = {}

    Returns void

  • _logError(user: any, action: any, subject: any, __namedParameters?: { parent: any; pack: any }): string
  • 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

  • #handleCreateDocuments(response: SocketResponse): Promise<Document[]>
  • Handle a SocketResponse from the server when one or multiple documents were created

    Parameters

    • response: SocketResponse

      The provided Socket response

    Returns Promise<Document[]>

    An Array of created Document instances

  • #handleUpdateDocuments(response?: SocketResponse): Promise<Document[]>
  • Handle a SocketResponse from the server when one or multiple documents were updated

    Parameters

    • response: SocketResponse = {}

      The provided Socket response

    Returns Promise<Document[]>

    An Array of updated Document instances

  • #handleDeleteDocuments(response?: SocketResponse): Promise<Document[]>
  • Handle a SocketResponse from the server where Documents are deleted.

    Parameters

    • response: SocketResponse = {}

      The provided Socket response

    Returns Promise<Document[]>

    An Array of deleted Document instances

  • #preCreateDocumentArray(documentClass: {}, request: SocketRequest, user: User): Promise<Document[]>
  • Perform a standardized pre-creation workflow for all Document types. For internal use only.

    Parameters

    • documentClass: {}
      • request: SocketRequest
      • user: User

      Returns Promise<Document[]>

    • #postCreateDocumentCallbacks(collection: DocumentCollection, result: any[], parent: ClientDocument, pack: string, options: any, userId: string): (() => Document)[]
    • Perform a standardized post-creation workflow for all Document types. For internal use only.

      Parameters

      • collection: DocumentCollection
      • result: any[]
      • parent: ClientDocument
      • pack: string
      • options: any
      • userId: string

      Returns (() => Document)[]

      An array of callback operations performed after every Document is created

    • Perform a standardized pre-update workflow for all Document types.

      Parameters

      Returns Promise<any[]>

    • #postUpdateDocumentCallbacks(collection: DocumentCollection, result: any[], options: any, userId: string): (() => Document)[]
    • Perform a standardized post-update workflow for all Document types.

      Parameters

      Returns (() => Document)[]

      An array of callback operations performed after every Document is updated

    • #preDeleteDocumentArray(collection: DocumentCollection, ids: string[], options: any, user: User): Promise<string[]>
    • Perform a standardized pre-delete workflow for all Document types.

      Parameters

      Returns Promise<string[]>

    • #postDeleteDocumentCallbacks(collection: DocumentCollection, ids: string[], options: any, userId: string): (() => Document)[]
    • Perform a standardized post-deletion workflow for all Document types.

      Parameters

      Returns (() => Document)[]

      An array of callback operations performed after every Document is deleted

    • #getParent(uuid: string, options?: any): Promise<ClientDocument>
    • Get the parent document for given request from its provided UUID, if any.

      Parameters

      • uuid: string

        The parent document UUID, or null

      • options: any = {}

      Returns Promise<ClientDocument>

      The parent document for the transaction

    • Obtain the document collection for a given Document type, parent, and compendium pack.

      Parameters

      • documentName: string

        The Document name

      • parent: any

        A parent Document, if applicable

      • pack: string

        A compendium pack identifier, if applicable

      Returns DocumentCollection | CompendiumCollection

      The relevant collection instance for this request

    • #buildRequest(request: SocketRequest): SocketRequest
    • Build a CRUD request.

      Parameters

      • request: SocketRequest

        The initial request data.

      Returns SocketRequest

    • #buildResponse(response: { action: string; documents: ClientDocument[]; options: any }): ClientDocument[]
    • Build a CRUD response.

      Parameters

      • response: { action: string; documents: ClientDocument[]; options: any }

        The response data.

        • action: string

          The type of response.

        • documents: ClientDocument[]

          The initial response result.

        • options: any

          The response options.

      Returns ClientDocument[]

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

      Parameters

      • parent: ClientDocument

        The parent Document

      Returns TokenDocument

      The Token ancestor, or null

    Properties

    #flagScopes: string[]

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