Body, Mind & Soul — API Reference
    Preparing search index...

    ArrayField subclass that supports key-based partial updates.

    When an update array contains items with a key field (default id, configurable via idKey option), each item is merged into the matching existing element rather than replacing the whole array. Merging is recursive: nested arrays whose items have id fields are also merged.

    Items without the key field in the update are ignored (to insert a new item, include a fresh key value). To replace the full array, omit the key from all items.

    To delete an item, include _delete: true alongside the key: { id: "abc", _delete: true } The _delete sentinel survives Foundry's cleanData pipeline via the _cleanType override.

    The _updateDiff override uses ForcedReplacement.create(merged) (v14 replacement for the deprecated ==key syntax) so the merged result is re-applied as a full replacement on the client round-trip, ensuring deletions are not silently restored by a second _mergeIdArray pass.

    The element field type

    ArrayField options

    Field name used as the merge key

    When true, inner arrays within a matched element are replaced outright rather than id-merged. Use this when matched elements always carry their complete inner-array state (e.g. combat downs, where the full actions list is always written). Leave false (default) for elements that send partial inner-array updates (e.g. swings, where a single trigger field may be patched).

    Hierarchy

    • any
      • MergeableArrayField
    Index
    • Parameters

      • element: any
      • options: {} = {}

      Returns MergeableArrayField

    idKey: any
    replaceInnerArrays: any
    • Override _cleanType to handle id-keyed partial updates correctly.

      Foundry's ArrayField._cleanType forces partial:false on all elements, which has two problems:

      1. It strips unknown keys like _delete (not in schema) from every element.
      2. It fills missing fields with schema defaults, causing _mergeWithIds to overwrite existing values with defaults for fields that weren't part of the intended update.

      This override:

      • Preserves _delete: true items (returns only idKey + _delete, skips element.clean entirely)
      • Cleans id-keyed items with partial:true so only present fields are validated/cast, avoiding unintended default injection into the merge.
      • Falls back to partial:false for items without the idKey (full-replacement semantics).

      Parameters

      • value: any
      • options: any
      • _state: any

      Returns any

    • Parameters

      • key: any
      • value: any
      • options: any
      • state: any

      Returns any