gpt4 book ai didi

firebase - 如何检查字段是否存在Firestore规则?

转载 作者:行者123 更新时间:2023-12-03 15:54:42 26 4
gpt4 key购买 nike

我有一个Firestore数据库,其中包含产品集合和类别集合。

我仅在类别文档没有products字段的情况下才向用户授予对类别集合的删除权限。

产品字段是一个引用数组。

我有以下规则:

match /shops/{shopId} {
allow read: if true;
allow write: if false;
match /categories/{category=**}{
allow read: if true;
allow write: if resource.data.products == null;
}
}

但是此规则不起作用,我无法编写或更新文档。

最佳答案

试试这个

match /shops/{shopId} {
allow read: if true;
allow write: if false;
match /categories/{category=**}{
allow read: if true;
allow create: if true;
allow update, delete: if !('products' in resource.data);
}
}

关于firebase - 如何检查字段是否存在Firestore规则?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61952920/

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