AngularFire collectionGroup 总是抛出错误不是一个有效的函数
AngularFire collectionGroup always throws error not a valid function
我正在使用 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
角火
火力基地
firebase-admin
但是错误还是出现了。此外,如果我尝试使用 .collection() 函数查询食谱集合,它只是 returns 一个空结果.. 即使“食谱”集合下有文档
您user
对象是firebase.firestore.DocumentReference
class的一个实例,它没有collectionGroup
方法。检查文档 here.
如果你想运行跨各种集合的查询,这些应该有相同的名字,你可以使用firebase.firestore().collectionGroup()
方法。您可以在 this link.
中找到如何配置它
如果您只想获取 recipe
集合中的所有文档,可以使用 CollectionReference.get()
方法 (documentation)。
我正在使用 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 角火 火力基地 firebase-admin
但是错误还是出现了。此外,如果我尝试使用 .collection() 函数查询食谱集合,它只是 returns 一个空结果.. 即使“食谱”集合下有文档
您user
对象是firebase.firestore.DocumentReference
class的一个实例,它没有collectionGroup
方法。检查文档 here.
如果你想运行跨各种集合的查询,这些应该有相同的名字,你可以使用firebase.firestore().collectionGroup()
方法。您可以在 this link.
如果您只想获取 recipe
集合中的所有文档,可以使用 CollectionReference.get()
方法 (documentation)。