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 https://firebase.google.com/docs/reference/admin/node/admin.firestore
您无法在任何上下文中或使用任何 SDK 使用通配符查询 Firestore。这是无效的:
firestore.collection(`card/{anyCard}/relatedCards`)
如果您要引用文档或集合,则需要提供其真实的路径。您不能对路径的任何部分使用通配符。
如果您尝试对已知集合和文档进行更简单的查询,它将正常工作。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)