Cloud Firestore安全规则-在列表请求中获取父文档

时间:2020-05-13 15:50:11

标签: firebase google-cloud-firestore firebase-security

im试图在用户列出子集合时检查父文档数据。 这是我的规则:

match /configs/{config}{
  //everybody can list the configs
  allow read: if isAuthenticated()
  match /sources/{source} {
    allow list:
      if isAuthenticated() && 
      canViewProduct(
        request.auth.token.email,database,
        get(/configs/$(config)).data.projectName,'filetransfer')
  }

但是,当我尝试如下所示的/ sources列表时,出现了错误:

app.collection("configs").doc("flow01").collection.("sources").get()

    FirebaseError: 
false for 'list' @ L117, Service call error. Function: [get], Argument: [path_value {
  segments {
    simple: "configs"
  }
  segments {
    simple: "flow01"
  }
}
]. for 'list' @ L131

我不明白为什么“ get(/ configs / $(config))”失败了,因为父文档“ flow01”存在...

我不能在 list 操作中使用 get()函数吗?

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

使用last index value.时,必须提供文档的完整路径。您现在所拥有的非常不完整-您不能使用任何相对路径。完整的from bs4 import BeautifulSoup html='''<span class="attribute-value"> <i class="icon icon_male_symbol"></i> <i class="icon icon_female_symbol"></i> </span>''' soup=BeautifulSoup(html,'html.parser') for item in soup.find('span',class_='attribute-value').find_all('i'): print(item['class'][-1]) 看起来像这样:

get()

我建议您还阅读安全规则中的accessing other documents文档。