An abstract subclass of the Collection container which defines a collection of Document instances.

Abstract

Param: data

An array of data objects from which to create document instances

Hierarchy (view full)

Properties

apps: Application[]

An Array of application references which will be automatically updated when the collection content changes

invalidDocumentIds: Set<string> = ...

Record the set of document ids where the Document was not initialized because of invalid source data

documentName: string

The base Document type which is contained within this DocumentCollection

#dataModelSearchFieldsCache: Map<string, Set<string>> = ...

The cache of search fields for each data model

Accessors

  • get documentClass(): typeof Document
  • A reference to the Document class definition which is contained within this DocumentCollection.

    Returns typeof Document

  • get documentName(): any
  • Returns any

    Inherit Doc

  • get name(): string
  • The Collection class name

    Returns string

Methods

  • Instantiate a Document for inclusion in the Collection.

    Parameters

    • data: object

      The Document data.

    • Optional context: object = {}

      Document creation context.

    Returns Document

  • Obtain a temporary Document instance for a document id which currently has invalid source data.

    Parameters

    • id: string

      A document ID with invalid source data.

    • Optional options: {
          strict: boolean;
      } = {}

      Additional options to configure retrieval.

      • strict: boolean

        Throw an Error if the requested ID is not in the set of invalid IDs for this collection.

    Returns Document

    An in-memory instance for the invalid Document

    Throws

    If strict is true and the requested ID is not in the set of invalid IDs for this collection.

  • Get an element from the DocumentCollection by its ID.

    Parameters

    • id: string

      The ID of the Document to retrieve.

    • Optional options: {
          strict: boolean;
          invalid: boolean;
      } = {}

      Additional options to configure retrieval.

      • strict: boolean

        Throw an Error if the requested Document does not exist.

      • invalid: boolean

        Allow retrieving an invalid Document.

    Returns Document

    Throws

    If strict is true and the Document cannot be found.

  • Parameters

    • id: any
    • document: any

    Returns void

    Inherit Doc

  • Parameters

    • id: any

    Returns boolean

    Inherit Doc

  • Render any Applications associated with this DocumentCollection.

    Parameters

    • force: any
    • options: any

    Returns void

  • Find all Documents which match a given search term using a full-text search against their indexed HTML fields and their name. If filters are provided, results are filtered to only those that match the provided values.

    Parameters

    • search: {
          query: string;
          filters: FieldFilter[];
          exclude: string[];
      }

      An object configuring the search

      • query: string

        A case-insensitive search string

      • filters: FieldFilter[]

        An array of filters to apply

      • exclude: string[]

        An array of document IDs to exclude from search results

    Returns string[]

  • Update all objects in this DocumentCollection with a provided transformation. Conditionally filter to only apply to Entities which match a certain condition.

    Parameters

    • transformation: object | Function

      An object of data or function to apply to all matched objects

    • condition: Function = null

      A function which tests whether to target each object

    • Optional options: object = {}

      Additional options passed to Document.updateDocuments

    Returns Promise<Document[]>

    An array of updated data once the operation is complete

  • Internal

    Follow-up actions to take when a database operation modifies Documents in this DocumentCollection.

    Parameters

    • action: DatabaseAction

      The database action performed

    • documents: ClientDocument[]

      The array of modified Documents

    • result: any[]

      The result of the database operation

    • operation: DatabaseOperation

      Database operation details

    • user: User

      The User who performed the operation

    Returns void

  • Private

    Initialize the DocumentCollection by constructing any initially provided Document instances

    Returns void

  • Get the searchable fields for a given document or index, based on its data model

    Parameters

    • documentName: string

      The document type name

    • Optional documentSubtype: string = ""

      The document subtype name

    • Optional isEmbedded: boolean = false

      Whether the document is an embedded object

    Returns Set<string>

    The dot-delimited property paths of searchable fields