Sequelize won't update JSON field under some circumstances.
For example, I have:
[[1]] (an array inside array)
And I'm trying push something:
instance.arr[0].push(1); // [[1,1]]
instance.save();
// or:
instance.update({arr: instance.arr});
Now inside instance I have changed array and nothing changed inside db. Not even a query is sent. :(
From sequelize website:
https://sequelize.org/master/manual/model-instances.html
The save method is optimized internally to only update fields that really
changed. This means that if you don't change anything and call save,
Sequelize will know that the save is superfluous and do nothing, i.e.,
no query will be generated (it will still return a Promise, but it
will resolve immediately).
That's good but seems like it doesn't work for json, can I do a force update?
As of today I have to do a deep copy of array to save it.
I'm using MariaDB IDK if that matters.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…