Meteor is not reactive when an object field which contains an array of objects changes?

Hi all, very confused as I’m experiencing some strange behaviour. I’ll leave the code out and just explain the situation in order to keep it short. Essentially I’m developing an online restaurant menu system. A user can add, edit and delete dishes stored under their restaurant object. A dish object is essentially this

dish = {
name: …
description: …
category: …
optionsets: []
}

Rather than building any edit functionality for the time being, I have robomongo running which allows me to edit the mongo database. If I edit a dishes name, description or category, I will see the dish update in real-time in my browser.

However if I edit the options within the option set array, I do not see any changes in real-time. Even when I refresh the page, the changes still aren’t showing. I have cleared all browsing data as well. However the data in the database has 100% been updated. An option object inside the optionset array is simply the following

option: {name:…, priceModifier: 1} . If I change either the option name or modifier, neither of those changes are reflected in real time. Even referring the page isn’t reflecting the changes. However adding a new dish with options seems to render perfectly fine so as long as it’s new.

Is this some sort of default behavior in order to keep the application optimized so every little tiny change in an objects sub-fields isn’t recalling the entire mongo array again? If so there must be a way around this right?

If this isn’t the case, then I guess I must have done something wrong on my end somewhere.

Any help is appreciated

I think this is due to Meteor mergebox property, and you can think array in JS is a type of special object literal, hope this link can explain the mergebox to you

As an experiment, it might be worth trying to modify the array from Meteor code instead, just to see whether that happens to work. As far as I can tell from the Meteor Guide (Schema Design) what you are doing should work, despite the fact that they are encouraging us to denormalize if the sub-document is large/complex.

Hey Sean, thanks for the link, after having a read of that, I think mergebox is indeed the culprit here. That might also explain why even after the page refreshed, the data isn’t updated. Mergebox musn’t be taking notice to the data in the subfields and so it’s not sending any changes.

As Greg said before, I understand that denormalization is common for nosql data however when making the decision to store the option object’s as a field of my object, I figured it would be less CPU intensive to do it this way as opposed to querying each option object everytime. Am I correct in thinking this?

Finally based on all this information, is my solution to simply do the above?

Thanks for the help sean

Gave it a shot by creating an edit meteor method. No luck :frowning: Might just have to denormalize.