question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FR: Expose entity metadata

See original GitHub issue

Is 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:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
mcrokercommented, Jan 14, 2021

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.

    syncWithRetry(delay: number = 100, ...args: string[]) {
        return this.sync(...args).pipe(
            catchError((error, obs) => {
                if (delay <= 3000 && error.name === 'FirebaseError' && error.code === 'permission-denied') {
                    console.log(`Permission denied ${args} - trying again in ${delay}ms`);
                    return timer(delay).pipe(take(1), switchMap(() => this.syncWithRetry(delay * 2, ...args)));
                }
                throw (error);
            })
        );
    }
1reaction
fritzschoffcommented, Jan 14, 2021

Well I guess I can implement a function that lets you operate on the meta data.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expose entity metadata type #1263 - PrismarineJS/mineflayer
I'm trying to work with some entity's metadata, so I access it using entity.metadata and that returns the metadata wich has been parsed ......
Read more >
Expose Entity Metadata property (for Search API, etc.) - Drupal
This module defines a field type. It should expose the corresponding entity metadata type so that the field can be indexed in Search...
Read more >
Entity modeling - Finance & Operations | Dynamics 365
The public entity name that is exposed in Dataverse metadata for the finance and operations virtual entity uses the physical name of the ......
Read more >
Retrieving Entity Metadata using the Web API - YouTube
In this video, I'll show you how to use the Dynamics 365 / Common Data Service Web API to retrieve metadata information relating...
Read more >
How-to: Consuming Exact Globe Next entity metadata services
The metadata service is used to retrieve information regarding entities. The information about the entities includes the list of the entities that are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found