I'm working with Angular Firestore and I've been struggling with this particular task the last two days. Here is what I need: When user taps the save button, I call:
save(group: IGroup){
if(group.id){
this.update(group);
}else{
this.create(group);
}
}
So far so good, it works fine when I call update and create methods. My problem is before calling the 'save' function in the first place. I have this schema:
(collection)groups -> (document)group -> (array)group.words
What I need to do is:
if(groups.last.words.length < 9){
save(groups.last)
}else{
save(new Group())
}
How can I achieve that by getting groups from Angular Firestore?