Minimise Document using Prototype
Quick question, I've got no idea what I'm doing so please excuse my ineptitude.
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.fields
There 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?Solution:Jump to solution
From a post elsewhere:
foundry.utils.diffObject(WallDocument.prototype.constructor._schema.initial(),canvas.walls.placeables[0].document.toObject(), {inner: true})
...2 Replies