我可以在云功能中以管理员身份使用通配符查询 firestore 吗?

乔什·皮特曼
exports.updateRelatedCards = functions.firestore
  .document('topic/{newTopic}')
  .onWrite((snap, context) => {
    const newTopic = snap.data();

    // search for the recieved title in a 'relatedCards' subcollection
    return firestore
      .collection(`card/{anyCard}/relatedCards`)
      .where('title', '==', newTopic.title)
      .get()
      .then(coll => {
        const list = coll.docs.map(doc => doc.data());
        return list ? list : 'nolist';
      })
      .then(list => console.log('list', list))
      .catch(error => console.log('error', error));
  });

是否可以.where()在云函数中具有通配符的 Firestore 查询上使用

尽管存在数据,但我一直得到一个空数组,我不明白我是在做什么,还是不可能。似乎没有提到对管理 Firestore 文档的查询https://firebase.google.com/docs/reference/admin/node/admin.firestore

道格史蒂文森

您不能在任何上下文或任何 SDK 中使用通配符查询 Firestore。这是无效的:

firestore.collection(`card/{anyCard}/relatedCards`)

如果您要引用文档或集合,则需要提供它的真实路径。您不能通配路径的任何部分。

如果您尝试对已知集合和文档进行更简单的查询,它会工作得很好。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

我可以限制Firestore数据库中的某些字段仅由Firebase管理员获取吗?

可以使用云功能在本地运行Firestore吗?

我可以查询Firestore中嵌套文档中的字段吗?

云功能可以绕过Firestore安全规则吗

我可以使用if else语句编写Firestore查询吗?

Firestore 查询侦听器可以“收听”云函数吗?

我可以使用GCP基础架构作为代码来设置Firebase Auth,Firestore,RDB,云功能吗?

可以在Firestore中重用uuid吗?

Firestore“无效查询”-我使用索引错误吗?

可以取消 Firestore 写操作吗?

Firestore 规则可以有例外吗?

Cloud Firestore:可以同步读取缓存吗?

PHP可以从Firebase / Firestore检索数据吗?

我可以在Firestore交易中遍历文档吗?

我可以在Firestore搜索中过滤多个字段吗?

我可以在Firestore Rules中创建地图吗?

我可以在Firestore中更改文档的名称吗?

我可以使用flutter在Firestore上创建索引吗?

我可以使用 nodejs 管理 sdk 对 Firestore 安全规则进行单元测试吗?

我可以在Cloud Firestore的子集合中查询和检索文档的字段值吗?

我可以使用where equals子句和orderby查询Cloud Firestore集合吗?

Firestore 的数据可以通过 angular 服务进行管理吗?

管理员可以使用SQL Server 2016始终加密功能查看加密数据吗?

如果我使用我的API密钥,可以向网络管理员公开吗?

Firestore - 可以通过数组不包含查询吗?

我可以授予用户编辑 Firestore 集合的权限吗?

我可以锁定客户端 Firestore 的读写操作吗?

如果我不是系统管理员,可以在Unix中构建python吗?

销毁失败时,我可以在活动管理员中收到闪现消息吗?