[英]Firestore security rules: not in condition
I have game interface with players limit and connected players (array of player ids)我有玩家限制和连接玩家的游戏界面(玩家ID数组)
interface IGameData { playersLimit: number; players: string[]; }
How to write a not in rule which will check if player that I'm requesting to push inside players array is already in the players array then the rule should deny request?如何编写一个不规则来检查我请求推入玩家数组的玩家是否已经在玩家数组中然后规则应该拒绝请求?
Update request looks like this更新请求看起来像这样
await updateDoc(
doc(db, 'games', gameId),
{
players: arrayUnion(playerId)
}
)
The arrayUnion
operator already prevents duplicates from appearing in the players array. arrayUnion
运算符已经防止重复项出现在玩家数组中。 You don't need a security rule for that.您不需要为此设置安全规则。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.