The compendium metadata, an object provided by game.data
A reference to the Application class which provides an interface to interact with this compendium content.
An Array of application references which will be automatically updated when the collection content changes
A subsidiary collection which contains the more minimal index of the pack
Record the set of document ids where the Document was not initialized because of invalid source data
The compendium metadata which defines the compendium content and location
Static
CACHE_The amount of time that Document instances within this CompendiumCollection are held in memory. Accessing the contents of the Compendium pack extends the duration of this lifetime.
Static
CONFIG_The named game setting which contains Compendium configurations.
Static
documentThe base Document type which is contained within this DocumentCollection
The banner image for this Compendium pack, or the default image for the pack type if no image is set.
The canonical Compendium name - comprised of the originating package and the pack name
Access the compendium configuration data for this pack
Return an Array of all the entry values in the Collection
A reference to the Document class definition which is contained within this DocumentCollection.
Has this compendium pack been fully indexed?
The index fields which should be loaded for this compendium pack
Track whether the Compendium Collection is locked for editing
The Collection class name
The visibility configuration of this compendium pack.
Get the sort order for this Compendium
A convenience reference to the label which should be used as the title for the Compendium pack.
Is this Compendium pack visible to the current game User?
Internal
Follow-up actions to take when a database operation modifies Documents in this DocumentCollection.
The database action performed
The array of modified Documents
The result of the database operation
Database operation details
The User who performed the operation
Then iterating over a Collection, we should iterate over its values instead of over its entries
Assign configuration metadata settings to the compendium pack
The object of compendium settings to define
A Promise which resolves once the setting is updated
Prompt the gamemaster with a dialog to configure ownership of this Compendium pack.
The configured ownership for the pack
Instantiate a Document for inclusion in the Collection.
The Document data.
Optional
context: object = {}Document creation context.
Delete an existing world-level Compendium Collection. This action may only be performed for world-level packs by a Gamemaster User.
Duplicate a compendium pack to the current World.
A new Compendium label
Filter the Collection, returning an Array of entries which match a functional condition.
The functional condition to test.
An Array of matched values
Find an entry in the Map using a functional condition.
The functional condition to test.
The value, if found, otherwise undefined
Apply a function to each element of the collection
A function to apply to each element
Get an element from the DocumentCollection by its ID.
The ID of the Document to retrieve.
Additional options to configure retrieval.
Get a single Document from this Compendium by ID. The document may already be locally cached, otherwise it is retrieved from the server.
The requested Document id
The retrieved Document instance
Load multiple documents from the Compendium pack using a provided query object. The available query options are shown below.
A database query used to retrieve documents from the underlying database
The retrieved Document instances
Load the Compendium index and cache it as the keys and values of the Collection.
Optional
options: { fields?: string[] } = {}Options which customize how the index is created
Optional
fields?: string[]An array of fields to return as part of the index
Obtain a temporary Document instance for a document id which currently has invalid source data.
A document ID with invalid source data.
Optional
options: { strict?: boolean } = {}Additional options to configure retrieval.
Optional
strict?: booleanThrow an Error if the requested ID is not in the set of invalid IDs for this collection.
An in-memory instance for the invalid Document
Get an entry from the Collection by name. Use of this method assumes that the objects stored in the collection have a "name" attribute.
The name of the entry to retrieve
Optional
options: { strict?: boolean } = {}Additional options that affect how entries are retrieved
Optional
strict?: booleanThrow an Error if the requested name does not exist. Default false.
The retrieved entry value, if one was found, otherwise undefined
Get the ownership level that a User has for this Compendium pack.
The user being tested
The ownership level in CONST.DOCUMENT_OWNERSHIP_LEVELS
Generate a UUID for a given primary document ID within this Compendium pack
The document ID to generate a UUID for
The generated UUID, in the form of "Compendium.
Fully import the contents of a Compendium pack into a World folder.
Optional
options: { folderId?: null | string; folderName?: string } = {}Options which modify the import operation. Additional options are forwarded to foundry.documents.abstract.WorldCollection#fromCompendium and foundry.abstract.Document.createDocuments
Optional
folderId?: null | stringAn existing Folder _id to use.
Optional
folderName?: stringA new Folder name to create.
The imported Documents, now existing within the World
Provide a dialog form that prompts the user to import the full contents of a Compendium pack into the World.
Optional
options: object = {}Additional options passed to the DialogV2.confirm method
A promise which resolves in the following ways: an array of imported Documents if the "yes" button was pressed, false if the "no" button was pressed, or null if the dialog was closed without making a choice.
Import a Document into this Compendium Collection.
The existing Document you wish to import
Optional
options: object = {}Additional options which modify how the data is imported. See ClientDocumentMixin#toCompendium.
The imported Document instance
Import a Folder into this Compendium Collection.
Import an array of Folders into this Compendium Collection.
Add a Document to the index, capturing its relevant index attributes
The document to index
Transform each element of the Collection into a new form, returning an Array of transformed values
A transformation function applied to each entry value. Positional arguments are the value, the index of iteration, and the collection being mapped.
An Array of transformed values
Migrate a compendium pack. This operation re-saves all documents within the compendium pack to disk, applying the current data model. If the document type has system data, the latest system data template will also be applied to all documents.
Reduce the Collection by applying an evaluator function and accumulating entries
A reducer function applied to each entry value. Positional arguments are the accumulator, the value, the index of iteration, and the collection being reduced.
An initial value which accumulates with each iteration
The accumulated result
Render any Applications associated with this DocumentCollection.
Force rendering
Optional options
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.
An object configuring the search
Optional
exclude?: string[]An array of document IDs to exclude from search results
Optional
filters?: FieldFilter[]An array of filters to apply
Optional
query?: stringA case-insensitive search string
Test whether a condition is met by some entry in the Collection.
The functional condition to test. Positional arguments are the value, the index of iteration, and the collection being tested.
Was the test condition passed by at least one entry?
Test whether a certain User has a requested permission level (or greater) over the Compendium pack
The User being tested
The permission level from DOCUMENT_OWNERSHIP_LEVELS to test
Additional options involved in the permission test
Optional
exact?: booleanRequire the exact permission level requested?
Does the user have this permission level over the Compendium pack?
Convert the Collection to a primitive array of its contents.
An array of contained values
Update all objects in this DocumentCollection with a provided transformation. Conditionally filter to only apply to Entities which match a certain condition.
An object of data or function to apply to all matched objects
A function which tests whether to target each object
Additional options passed to Document.updateDocuments
An array of updated data once the operation is complete
Protected
_initializeProtected
Initialize the DocumentCollection by constructing any initially provided Document instances
Static
_activateInternal
Activate the Socket event listeners used to receive responses to compendium management events.
The active game socket.
Static
_onHandle changes to the world compendium configuration setting.
Static
createCreate a new Compendium Collection using provided metadata.
The compendium metadata used to create the new pack
Additional options which modify the Compendium creation request
Static
getGet the searchable fields for a given document or index, based on its data model
The document name
Optional
type: stringA document subtype
A record of searchable DataField definitions
A collection of Document objects contained within a specific compendium pack. Each Compendium pack has its own associated instance of the CompendiumCollection class which contains its contents.
Hook Events
See
foundry.Game#packs