An abstract base class extended on both the client and server which defines how Documents are retrieved, created, updated, and deleted.

Alias

foundry.abstract.DatabaseBackend

Abstract

Hierarchy (view full)

Methods

  • 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

  • Create new Documents using provided data and context. It is recommended to use Document.createDocuments or Document.create rather than calling this method directly.

    Parameters

    • documentClass: typeof Document

      The Document class definition

    • operation: DatabaseCreateOperation

      Parameters of the create operation

    • Optional user: BaseUser

      The requesting User

    Returns Promise<Document[]>

    An array of created Document instances

  • Update Documents using provided data and context. It is recommended to use Document.updateDocuments or Document#update rather than calling this method directly.

    Parameters

    • documentClass: typeof Document

      The Document class definition

    • operation: DatabaseUpdateOperation

      Parameters of the update operation

    • Optional user: BaseUser

      The requesting User

    Returns Promise<Document[]>

    An array of updated Document instances

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

    Returns string[]

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

    Returns string[]

  • Protected

    Log a database operations message.

    Parameters

    • level: string

      The logging level

    • message: string

      The message

    Returns void

    Abstract

  • 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

  • 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