gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 03:36:55 24 4
gpt4 key购买 nike

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));
});

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

尽管存在数据,但我一直得到一个空数组,我不明白我是在做某事还是做不到。似乎没有提及在管理员 firestore 文档上查询 https://firebase.google.com/docs/reference/admin/node/admin.firestore

最佳答案

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

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

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

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

关于firebase - 我可以在云功能中以管理员身份使用通配符查询 firestore 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49912812/

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