The name of this collection in the parent Document.
The parent Document instance to which this collection belongs.
The source data array for the collection in the parent Document data.
The source data array from which the embedded collection is created
The Document implementation used to construct instances within this collection.
Record the set of document ids where the Document was not initialized because of invalid source data
The parent Document to which this EmbeddedCollection instance belongs.
The name of this collection in the parent Document.
Protected
_initializedHas this embedded collection been initialized as a one-time workflow?
Return an Array of all the entry values in the Collection
The Document name of Documents stored in this collection.
This collection's contents grouped by subtype, lazily (re-)computed as needed. If the document type does not support subtypes, all will be in the "base" group.
Internal
Follow-up actions to take when a database operation modifies Documents in this EmbeddedCollection.
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
Instantiate a Document for inclusion in the Collection.
The Document data.
Optional
context: DocumentConstructionContext = {}Document creation context.
The embedded Document ID.
Optional
options: { modifySource?: boolean } = {}Additional options to the delete operation.
Optional
modifySource?: booleanWhether to modify the collection's source as part of the operation.
Filter the Collection, returning an Array of entries which match a functional condition.
The functional condition to test. Positional arguments are the value, the index of iteration, and the collection being filtered.
An Array of matched values
Find an entry in the Map using a functional condition.
The functional condition to test. Positional arguments are the value, the index of iteration, and the collection being searched.
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 EmbeddedCollection by its ID.
The ID of the Embedded Document to retrieve.
Optional
options: { invalid?: boolean; strict?: boolean } = {}Additional options to configure retrieval.
Optional
invalid?: booleanAllow retrieving an invalid Embedded Document.
Optional
strict?: booleanThrow an Error if the requested Embedded Document does not exist.
The retrieved document instance, or undefined
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
Initialize the EmbeddedCollection by synchronizing its Document instances with existing _source data. Importantly, this method does not make any modifications to the _source array. It is responsible for creating, updating, or removing Documents from the Collection.
Optional
options: DocumentConstructionContext = {}Initialization options.
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
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
Add an item to the collection.
The embedded Document ID.
The embedded Document instance.
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?
Convert the Collection to a primitive array of its contents.
An array of contained values
Convert the EmbeddedCollection to an array of simple objects.
Optional
source: boolean = trueDraw data for contained Documents from the underlying data source?
The extracted array of primitive objects
Protected
_handleProtected
Log warnings or errors when a Document is found to be invalid.
The invalid Document's ID.
The validation error.
Optional
options: { strict?: boolean } = {}Options to configure invalid Document handling.
Optional
strict?: booleanWhether to throw an error or only log a warning.
Protected
_initializeProtected
Initialize an embedded document and store it in the collection. The document may already exist, in which case we are reinitializing it with new _source data. The document may not yet exist, in which case we create a new Document instance using the provided source.
The Document data.
Optional
options: DocumentConstructionContextInitialization options.
The initialized document or null if no document was initialized
This class provides a foundry.utils.Collection wrapper around a singleton embedded Document so that it can be interacted with via a common interface.