Minimise Document using Prototype
Say I have a document, e.g. a wall:
But I want to minimise it down to only the changed data from the defaults.
I can check the defaults in
WallDocument.prototype.constructor._schema.fieldsThere I see that
light always has an initial value of 20 so we can remove that.We also bin off the
_id as we know we'll get a new one.A simplified object for this example would then be:
Is there a trivial/simple way to use the wall prototype to reduce full data to just the non-default fields?
foundry.utils.diffObject(WallDocument.prototype.constructor._schema.initial(),canvas.walls.placeables[0].document.toObject(), {inner: true})