FR: Expose entity metadata
See original GitHub issueIs it possible to expose the object metadata through the akita entity store…
As I’m in danger of jumping to the solution, the challenge I have is starting a dynamic store for a subcollection before the parent collection is created fully…
Give a firestore structure of … /{library}/books/{book}
I am:
- creating the library using the libraryService.add() function.
- listening on libraryQuery.selectAll() to create a dynamic books entitystore for each library which syncs to /{library}/books/{book}
- The library object includes the owner which is used in the firestore rules for both library and the books subcollection for each library.
I’m getting beaten by a race-condition… libraryService.selectAll() includes the new library, before firebase will accept the sync() collection query for the books SubCollection. It is failing with an insufficient permissions error.
Looking at the metadata property , I believe the issue that that the subCollection query is not accepted until the hasPendingWrites property on the doc metadata object returned by return this.db.collection(path, queryFn).stateChanges() is false. metadata: {hasPendingWrites: false, fromCache: false}
I can currently find no way of detecting this when using syncCollection() - hence my request to expose the metadata.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Top GitHub Comments
Firstly THANK-YOU for such a swift response, once again proving the OSS community is faster and often more helpful than commercial software…
The fix didn’t actually do the job. Not because of it’s implementation, but because I missunderstood the problem. The problem I have is because there security rules rely on the content of the record, I can’t even query it for metadata until firebase finishes it’s back end… I’m not quire sure why it appears in the library collection selectAll() prior to this, but it definitely does.
In the interim I’ve implemented this (rather ugly, but effective) workaround, which catches the permissions error and implements an exponential retry. It seems on my high-bandwidth home network to resolve inside 100ms the vast majority of the time.
Well I guess I can implement a function that lets you operate on the meta data.