![](/img/trans.png)
[英]Firestore security rules: check a condition for every value in an array
[英]Firestore security rules: not in condition
我有玩家限制和連接玩家的游戲界面(玩家ID數組)
interface IGameData { playersLimit: number; players: string[]; }
如何編寫一個不規則來檢查我請求推入玩家數組的玩家是否已經在玩家數組中然后規則應該拒絕請求?
更新請求看起來像這樣
await updateDoc(
doc(db, 'games', gameId),
{
players: arrayUnion(playerId)
}
)
arrayUnion
運算符已經防止重復項出現在玩家數組中。 您不需要為此設置安全規則。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.