This is a function to add a dictionary as a subitem of a main document.
addSubItem = function(id, data) {
s = Item.findOne(id);
if(s){
Item.update({_id:id},{$push:{'subItemsList':data}});
}
};
I verify the data passed and are a valid main document id a subitem data.
data = {num:1, value: 'Subitem1'};
This works fine yesterday with the latest version of meteor (0.4.2), but today I get this message at javascript console:
Error: Cannot apply $push modifier to non-array
I created and setup a new project and I still get the same.
Thanks to Lloyd, Nice workaround and thanks for the javascript crash course (i’m a begginer on it), but I found the solution: (note the “$push”)