How can i interrupt an insert by checking some condition in the before hook?
Collection.before.insert((userId, doc) => {
if(doc.property != valid){
// interrupt insert here
}
});
i tried throw new Meteor.Error('Insert Error','Not Allowed...')
but this didn't interrupt the process of the insert.
Another possibility would be, to go in the after hook and delete the inserted document.... but this is an ugly solution.
You can prevent the insertion by returning false
.