Meteor JS - 允许/拒绝规则

Jev*_*ads 5 meteor

在示例应用程序"派对"中,有一组允许/拒绝规则供缔约方收集.insert看起来像这样的规则:

Parties.allow({
  insert: function (userId, party) {
    return false; // no cowboy inserts -- use createParty method
  },...
Run Code Online (Sandbox Code Playgroud)

同时方法createParty实现了Parties.insert({....}),它在某种程度上不受应用于缔约方集合的规则的影响.

.....
return Parties.insert({
      owner: this.userId,
      x: options.x,
      y: options.y,
      title: options.title,
      description: options.description,
      public: !! options.public,
      invited: [],
      rsvps: []
    });
.....
Run Code Online (Sandbox Code Playgroud)

有人可以解释为什么createParty方法不受规则影响吗?

谢谢.

Aks*_*hat 10

createParty就是在 Meteor.methods其被调用的服务器上运行,以及客户端Meteor.call('createParties')从客户端.在客户端上它不会插入任何数据,但在服务器上运行的方法将插入该方.

流星allowdeny规则直接控制来自客户端的内容,不适用于在服务器端运行的任何内容.