Is it possible to just merge new or existing values on a JSON field?
I have
settings
field with various settings, and would like to not remove old entries that are not available in a given form.
e.g.
and
I would like to keep what is under "layout" but just add is_valid if it does not exist or update if it does, so the end json would look like:
4 Replies
so
'settings.layout.is_restaurant'
nesting is unlimitedyeh but if I hit save the layout.is_restaurant is gone
There might be many various settings stored on the column.
I was wondering if there is a possibility to just merge and not completely overwrite.
ah right
maybe use mutateDataBeforeSave()?
Yeh, this works. π
oh it looks like this preserves old values too if you write like so
If statePath empty then it just saves what is in the schema.
I am leaving this for future reference if someone will be looking for similar.