Get the permission level that a specific User has over this Document, a value in CONST.DOCUMENT_OWNERSHIP_LEVELS.
The User being tested
A numeric permission level from CONST.DOCUMENT_OWNERSHIP_LEVELS or null
Test whether a certain User has a requested permission level (or greater) over the Document
The User being tested
The permission level from DOCUMENT_OWNERSHIP_LEVELS to test
Additional options involved in the permission test
Does the user have this permission level over the Document?
Test whether a given User has permission to perform some action on this Document
The User attempting modification
The attempted action
Does the User have permission?
Clone a document, creating a new document by combining current data with provided overrides. The cloned document is ephemeral and not yet saved to the database.
Additional context options passed to the create method
The cloned Document instance
For Documents which include game system data, migrate the system data object to conform to its latest data model. The data model is defined by the template.json specification included by the game system.
The migrated system data object
Update this Document using incremental data, saving it to the database.
The updated Document instance
Delete this Document, removing it from the database.
The deleted Document instance
Obtain a reference to the Array of source data within the data object for a certain embedded Document name
The name of the embedded Document type
The Collection instance of embedded Documents of the requested type
Get an embedded document by it's id from a named collection in the parent document.
The name of the embedded Document type
The id of the child document to retrieve
Additional options which modify how embedded documents are retrieved
The retrieved embedded Document instance, or undefined
Create multiple embedded Document instances within this parent Document using provided input data.
The name of the embedded Document type
An array of data objects used to create multiple documents
An array of created Document instances
Update multiple embedded Document instances within a parent Document using provided differential data.
The name of the embedded Document type
An array of differential data objects, each used to update a single Document
An array of updated Document instances
Delete multiple embedded Document instances within a parent Document using provided string ids.
The name of the embedded Document type
An array of string ids for each Document to be deleted
An array of deleted Document instances
Get the value of a "flag" for this document See the setFlag method for more details on flags
The flag scope which namespaces the key
The flag key
The flag value
Assign a "flag" to this document. Flags represent key-value type data which can be used to store flexible or arbitrary data required by either the core software, game systems, or user-created modules.
Each flag should be set using a scope which provides a namespace for the flag to help prevent collisions.
Flags set by the core software use the "core" scope. Flags set by game systems or modules should use the canonical name attribute for the module Flags set by an individual world should "world" as the scope.
Flag values can assume almost any data type. Setting a flag value to null will delete that flag.
The flag scope which namespaces the key
The flag key
The flag value
A Promise resolving to the updated document
Remove a flag assigned to the document
The flag scope which namespaces the key
The flag key
The updated document instance
Copy and transform the DataModel into a plain object. Draw the values of the extracted object from the data source (by default) otherwise from its transformed values.
Perform preliminary operations before a Document of this type is created. Pre-creation operations only occur for the client which requested the operation. Modifications to the pending document before it is persisted should be performed with this.updateSource().
The initial data object provided to the document creation request
Additional options which modify the creation request
The User requesting the document creation
Perform preliminary operations before a Document of this type is updated. Pre-update operations only occur for the client which requested the operation.
The differential data that is changed relative to the documents prior values
Additional options which modify the update request
The User requesting the document update
Perform preliminary operations before a Document of this type is deleted. Pre-delete operations only occur for the client which requested the operation.
Additional options which modify the deletion request
The User requesting the document deletion
Perform follow-up operations after a Document of this type is created. Post-creation operations occur for all clients after the creation is broadcast.
The initial data object provided to the document creation request
Additional options which modify the creation request
The id of the User requesting the document update
Perform follow-up operations after a Document of this type is updated. Post-update operations occur for all clients after the update is broadcast.
The differential data that was changed relative to the documents prior values
Additional options which modify the update request
The id of the User requesting the document update
Perform follow-up operations after a Document of this type is deleted. Post-deletion operations occur for all clients after the deletion is broadcast.
Additional options which modify the deletion request
The id of the User requesting the document update
Define the data schema for documents of this type. The schema is populated the first time it is accessed and cached for future reuse.
Migrate candidate source data for this DataModel which may require initial cleaning or transformations.
The candidate source data from which the model will be constructed
Test whether a given User has a sufficient role in order to create Documents of this type in general.
The User being tested
Does the User have a sufficient role to create?
Create multiple Documents using provided input data. Data is provided as an array of objects where each individual object becomes one new Document.
An array of data objects used to create multiple documents
An array of created Document instances
Update multiple Document instances using provided differential data. Data is provided as an array of objects where each individual object updates one existing Document.
An array of differential data objects, each used to update a single Document
An array of updated Document instances
Delete one or multiple existing Documents using an array of provided ids. Data is provided as an array of string ids for the documents to delete.
An array of string ids for the documents to be deleted
An array of deleted Document instances
Create a new Document using provided input data, saving it to the database.
The created Document instance
Get a World-level Document of this type by its id.
The Document ID
The retrieved Document, or null
Define a simple migration from one field name to another. The value of the data can be transformed during the migration by an optional application function.
The data object being migrated
The old field name
The new field name
Perform follow-up operations when a set of Documents of this type are created. This is where side effects of creation should be implemented. Post-creation side effects are performed only for the client which requested the operation.
The Document instances which were created
The context for the modification operation
Perform follow-up operations when a set of Documents of this type are updated. This is where side effects of updates should be implemented. Post-update side effects are performed only for the client which requested the operation.
The Document instances which were updated
The context for the modification operation
Perform follow-up operations when a set of Documents of this type are deleted. This is where side effects of deletion should be implemented. Post-deletion side effects are performed only for the client which requested the operation.
The Document instances which were deleted
The context for the modification operation
The canonical identifier for this Document.
Test whether this Document is embedded within a parent Document
The database backend used to execute operations and handle results.
Return a reference to the configured subclass of this base Document type.
The named collection to which this Document belongs.
The canonical name of this Document type, for example "Actor".
Does this Document definition include a SystemDataField?
Default metadata which applies to each instance of this Document type.
The default icon used for newly created Macro documents
The Document definition for a RollTable. Defines the DataSchema and common behaviors for a RollTable which are shared between both client and server.