gpt4 book ai didi

Meteor JS - 允许/拒绝规则

转载 作者:行者123 更新时间:2023-12-03 23:06:57 24 4
gpt4 key购买 nike

在示例应用程序“派对”中,有一组用于派对收集的允许/拒绝规则。insert 的规则看起来像这样:

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

同时,方法 createParty 实现了 Party.insert({....}),它在某种程度上不受应用于 Party 集合的规则的影响。
.....
return Parties.insert({
owner: this.userId,
x: options.x,
y: options.y,
title: options.title,
description: options.description,
public: !! options.public,
invited: [],
rsvps: []
});
.....

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

谢谢你。

最佳答案

createPartyMeteor.methods它通过调用 Meteor.call('createParties') 在服务器端和客户端运行。从客户端。在客户端它不会插入任何数据,但在服务器上运行的方法将插入派对。

meteor allowdeny规则直接控制来自客户端的内容,而不适用于服务器端运行的任何内容。

关于Meteor JS - 允许/拒绝规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14547929/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com