如何中断在 before 钩子中插入的流星集合?

Howto interrupt meteor collections insert in the before hook?

如何通过检查 before 钩子中的某些条件来中断插入?

Collection.before.insert((userId, doc) => {
  if(doc.property != valid){
    // interrupt insert here
  }
});

我尝试了 throw new Meteor.Error('Insert Error','Not Allowed...') 但这并没有中断插入过程。

另一种可能性是进入 after 挂钩并删除插入的文档....但这是一个丑陋的解决方案。

您可以通过返回 false 来阻止插入。