When removing object from array, left with null instead of complete removal at index
Opened this issue · 1 comments
avishaan commented
When I remove something like the below:
it looks like it get's removed, but when I go back to the document I see it as a blank entry
when checking in the database, I see that null is left behind instead of the array element being removed
it really should remove the entire element of the array, not replace it with null
avishaan commented
because this package depends on https://github.com/aldeed/meteor-simple-schema#validating-data I realized I could just delete those null values upon save with a simple one-liner as follows in the autoValue function
Layouts.attachSchema(new SimpleSchema({
'orgID': {
'type': String,
'label': 'Unique Id',
'max': 50,
},
'categoryIds': {
'type': [String],
'label': 'Category Ids the schema applies to',
},
'graphs': {
type: [ChartSchema],
'autoValue': function() {
// remove the null in array on update https://github.com/orionjs/orion/issues/429
return this.value.filter(value => value !== null);
},
},
}));
Although it seems this issue presents itself in the actual dependency, I thought it would be helpful to have a post here as well for future reference