Closed luke-rogers closed 3 years ago
Hey, thanks for the issue. Will have a look asap.
Why don't you check before you are syncing if the sub collection exists? Or you use the startWith operator from rxjs to see if the second parameter is undefined and if so, you know that there is no sub collection. But I'm happy to review your PR if you already got a nice solution for your problem.
I ended up adding a tap
onto the syncActive
to update the store with the default value and active id if the sync returned null.
Alright! Closing the issue for now.
I am in the process of adding a new sub collection and am using route guards to keep this in sync.
There is one route where I need to sync the parent and this new sub collection - basically the document in sub collection will have same id as one in parent, I'm just using it to reduce size of document in parent query as we can't selectively load data using firestore.
When loading the documents in a service I am combining the data from the two documents using something similar to below.
It's possible that the document in
this.childQuery
won't exist so the above code won't emit as I am usingfilterNil
at the end. I would just remove that but the consuming component is usingtake(1)
so I would only want it to take when all of the data is available.I am sure I could probably work around this in other ways but it would be nice if I could provide a default value when the document doesn't exist in firestore.
Seems like that just need a change here although it might be useful to also add it to other methods such as
syncDoc
.Happy to have a go at raising a PR for this if you think its a worth while change.