javascript - AngularFire collectionGroup 总是抛出错误不是一个有效的函数
问题描述
我正在使用 Ionic 4,并且刚刚与 AngularFire 集成。集合和文档运行良好,但是我无法使 collectionGroup 函数正常工作 - 它总是给出该函数不存在的错误。
相关代码是:
this.user = this.firestore.collection('profile').doc(tok.uid);
async StoreRecipe(recipe_name,meal) {
var ua = await this.read_foods_meal(meal+1)
console.log(meal);
ua.subscribe( foods => { console.log(foods);
foods.forEach(food => { this.user.collection('recipe').doc(recipe_name).collection('foods').add(food);} )
});
}
async read_recipes() {
var ua = await this.user.collectionGroup('recipe');
return(ua);
}
我已将名称中带有“Fire”的所有模块更新为最新版本:@angular/fire @ionic-native/firebase-x angularfire firebase firebase-admin
但错误仍然出现。此外,如果我尝试使用 .collection() 函数查询食谱集合,它只会返回一个空结果..即使“食谱”集合下有文档
解决方案
You user
object is an instance of the firebase.firestore.DocumentReference
class, and it does not have a collectionGroup
method. Check the documetation here.
If you want to run a query across various collections, these should have the same name, and you can use the firebase.firestore().collectionGroup()
method. You can find how to configure it in this link.
If you just want to get all the documents inside your recipe
collection, you can make use of the CollectionReference.get()
method (documentation).
推荐阅读
- git - 为大量文件和过滤(clean = sha1sum)存储库加速 git add
- javascript - 如何在javascript中调用自身内部的函数?
- python - 如何创建一个值基于索引数组的布尔数组?
- java - mvn clean package 出错,声称我的目录中没有 POM,当我这样做时
- java - 无法解析 PowerMockito 但 PowerMockRunner 可以
- material-ui - type=date 的 TextField 组件创建不需要的日历图标
- c++ - 向 std::runtime_error 添加额外的字符串
- java - 没有整数溢出风险的类标识符
- javascript - 在前端上传图片上传时无法读取未定义的属性“路径”(反应)
- python - Python中的Selenium if else如何使用