I'm using Mongoose with Next.js, I made a model for User with one "page" object, and every time there is any change inside, I just update it as:
xUser.page.array = * the new array *
and it works well, now I made a new option to add something to the array, and it works well as:
xUser.page.array.push({ key1: value1, key2: value2, })
but now i decided to create a new key, "value3" and I'm trying to push it like that:
xUser.page.array.push({ key1: value1, key2: value2, key3: value3})
and after that:
user.markModified('page')
await user.save()
it does save the object inside the array, but without the new key and value ("key3") and when I console.log the memorized array (xUser.page.array) it does show the new key&value in the inserted object, but as I said not in the db as well :/ how can I add the new key&value? thanks!
Critical edit: looks like when i remove one key value from the object and push, for exa { key2: value2, key3: value3 } (without key1/val1) it does work, so somehow its limited to just 2 key values..