Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular Firestore-如何在没有它的情况下获取文档';s键_Angular_Google Cloud Firestore_Angularfire2_Angularfire5 - Fatal编程技术网

Angular Firestore-如何在没有它的情况下获取文档';s键

Angular Firestore-如何在没有它的情况下获取文档';s键,angular,google-cloud-firestore,angularfire2,angularfire5,Angular,Google Cloud Firestore,Angularfire2,Angularfire5,我在Angular Firestore工作,在过去两天里,我一直在努力完成这项特殊任务。我需要的是:当用户点击保存按钮时,我调用: save(group: IGroup){ if(group.id){ this.update(group); }else{ this.create(group); } } 到目前为止还不错,当我调用update和create方法时,它工作得很好。我的问题是在调用“save”函数之前。我有这个模式: (collection)groups -> (

我在Angular Firestore工作,在过去两天里,我一直在努力完成这项特殊任务。我需要的是:当用户点击保存按钮时,我调用:

save(group: IGroup){
 if(group.id){
  this.update(group);
 }else{
  this.create(group);
 }
}
到目前为止还不错,当我调用update和create方法时,它工作得很好。我的问题是在调用“save”函数之前。我有这个模式:

(collection)groups -> (document)group -> (array)group.words
我需要做的是:

if(groups.last.words.length < 9){
  save(groups.last)
}else{
  save(new Group())
}
if(groups.last.words.length<9){
保存(组。最后一个)
}否则{
保存(新组())
}

如何通过从Angular Firestore获取组来实现这一点?

好吧,我通过声明解决了我的问题:

words: Array<IWord>;

然后我从我的“单词”数组中得到了我的对象。

你是说你想在不知道文档ID的情况下获取一个特定的文档?您是否让Firestore生成文档ID?是和是。我使用map和snapshot值来获得文档ID。因此,在对
(array)组.words进行更改之前,您不会获取文档。在调用
save()
方法之前,是否可以再显示您正在执行的操作的代码?@NicholasPesa感谢您对此进行了思考。我只是设法解决了我的问题:)
this.words$.subscribe( result => {
  this.words = result;
});