You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Firestore规则中get()方法行为异常(疑似Bug)

Firestore规则中get()方法行为异常(疑似Bug)

我最近在Firestore规则里写了个测试函数,碰到了个离谱的问题,跟大家说说:

我写的规则函数是这样的:

function rulesTest() {
  let doc = get(/databases/$(database)/documents/someCollection/someDocId);
  return doc == null;
}

根据Firestore官方文档对get()方法的描述,它的返回值是:

non-null rules.firestore.Resource the document, or null if it does not exist

我在空数据库里测试这个函数——数据库里既没有someCollection集合,也没有someDocId文档,按预期doc应该是null,所以rulesTest()应该返回true才对。

可实际运行结果却是false!

更诡异的是:哪怕我把返回语句改成return doc != null,这个函数居然还是返回false?!

补充一下:这个问题是在Firestore模拟器里出现的。

备注:内容来源于stack exchange,提问作者Lara

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 15:53:02