向从 geofirestore 查询返回的每个文档添加一个子集合

问题描述

我有一个 Firestore 集合 crews/{crewid}/pros。 在云函数中 geofirestore 查询此集合后,我可以获得一些地理文档快照(doc)。现在我想随后在从查询返回的每个文档(doc)下添加一个新集合 crews/{crewid}/pros/{proid}/notifs。我想在 firestore 中得到的结果是这样的;

这是我的代码

exports.sendNotification = functions.firestore
.document("users/{userId}/clients/{client}")
.onCreate(async snapshot => {

     //my query here

 query.get().then( querySnapshot => {
    
    querySnapshot.forEach(async doc => {
               
        await doc.ref.collection('notifs').add({
            'field': clientfield,... });

        });
     }).catch ((error) =>
        console.log(error)
    );
})

但是在执行此代码后,firestore 中没有任何反应,并且云函数控制台显示错误“TypeError:无法读取未定义的属性“集合”。 应该修复什么以随后在“pro”文档下添加子集合“notifs”?感谢您的帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)