I have defined my filed and shema as:
storageArticles:
{
type: Array,
autoValue: function() {
return [];
},
label: 'Articless added to storage.',
},
'storageArticles.$': {
type: String
}
When I try to update this field by using (in my server side method):
Storages.update(storageId , {$set: { "storageArticles" : articleId }});
Everything goes OK, but data is no added to Array.
Can you give me some guidance to solve this.
EDIT
Edit adds more details on this question, maybe here is my mistake.
'articles.articleAddToStorage': function articleAddToStorage(storageId,articleId) {
check(storageId, String);
check(articleId, String);
try {
Articles.update(articleId, { $set: {articleAssignedToStorage:true}});
Storages.update(storageId , {$addToSet: { "storageArticles" : articleId }});
} catch (exception) {
handleMethodException(exception);
}
}
handleAddToStorage()
{
const articleId = this.props.articleId;
const storageId = this.state.storageId;
const history = this.props.history;
if(storageId!="")
{
Meteor.call('articles.articleAddToStorage', storageId,articleId, (error) => {
if (error) {
Bert.alert(error.reason, 'danger');
} else {
Bert.alert("Article assigned to storage", 'success');
}
});
}
else {
Bert.alert("Plese select storage", 'warning');
}
}