The name of this collection in the parent Document.
The parent DataModel instance to which this collection belongs.
The source data array for the collection in the parent Document data.
The Document implementation used to construct instances within this collection.
The name of this collection in the parent Document.
The parent DataModel to which this EmbeddedCollection instance belongs.
Record the set of document ids where the Document was not initialized because of invalid source data
Protected
_initializedHas this embedded collection been initialized as a one-time workflow?
Private
_sourceThe source data array from which the embedded collection is created
Get an element from the EmbeddedCollection by its ID.
The ID of the Embedded Document to retrieve.
Optional
options: { Additional options to configure retrieval.
Throw an Error if the requested Embedded Document does not exist.
Allow retrieving an invalid Embedded Document.
If strict is true and the Embedded Document cannot be found.
Add an item to the collection.
The embedded Document ID.
The embedded Document instance.
Optional
options: { Additional options to the set operation.
Whether to modify the collection's source as part of the operation.
Obtain a temporary Document instance for a document id which currently has invalid source data.
A document ID with invalid source data.
Optional
options: { Additional options to configure retrieval.
Throw 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
If strict is true and the requested ID is not in the set of invalid IDs for this collection.
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
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
let c = new Collection([["a", "A"], ["b", "B"], ["c", "C"]]);
c.get("a") === c.find(entry => entry === "A"); // true
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
let c = new Collection([["a", "AA"], ["b", "AB"], ["c", "CC"]]);
let hasA = c.filters(entry => entry.slice(0) === "A");
Apply a function to each element of the collection
A function to apply to each element
Array#forEach
let c = new Collection([["a", {active: false}], ["b", {active: false}], ["c", {active: false}]]);
c.forEach(e => e.active = true);
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: { Additional options that affect how entries are retrieved
Throw an Error if the requested name does not exist. Default false.
The retrieved entry value, if one was found, otherwise undefined
let c = new Collection([["a", "Alfred"], ["b", "Bob"], ["c", "Cynthia"]]);
c.getName("Alfred"); // "Alfred"
c.getName("D"); // undefined
c.getName("D", {strict: true}); // throws Error
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
let c = new Collection([["a", "A"], ["b", "B"], ["c", "C"]]);
let letters = c.reduce((s, l) => {
return s + l;
}, ""); // "ABC"
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?
Protected
_initializeProtected
_handleProtected
Log warnings or errors when a Document is found to be invalid.
The invalid Document's ID.
The validation error.
Optional
options: { Options to configure invalid Document handling.
Whether to throw an error or only log a warning.
Protected
_setProtected
_deleteProtected
_create
An extension of the Collection. Used for the specific task of containing embedded Document instances within a parent Document.