Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple queries in one <Firestore> #4

Open
wojciech111 opened this issue Jun 17, 2019 · 0 comments
Open

Multiple queries in one <Firestore> #4

wojciech111 opened this issue Jun 17, 2019 · 0 comments

Comments

@wojciech111
Copy link

wojciech111 commented Jun 17, 2019

First thanks for simple and super useful solution. It looks awesome but I found problem when I try to get two different documents to one page. I know that noSQL db should be optimized to access only one doc but there are cases when this just don't feel right.

Than I need to do workaround like this:

const DataProvider = ({ journeyId,personId,children }) => {
    return (
        <Suspense fallback={<p>Loading user data...</p>}>
            <Firestore
                query={({ firestore }) => firestore.collection('journeys').doc(journeyId)}
            >
                {({ data: journey }) => (
                    <Firestore
                        query={({ firestore }) => firestore.collection('persons').doc(personId)}
                    >
                        {({ data: person,firestore }) => (
                            <Fragment>
                                {children({ journey,person,firestore })}
                            </Fragment>
                        )}
                    </Firestore>
                )}
            </Firestore>
        </Suspense>
    );
};

This approach seems to have one minus that on journeys change the lower level component got rerendered and fetch again the same person document.
I glanced at your implementation and saw that you are hashing queries. This looks like adding queries::Array parameter to Firestore shouldn't be super challenging. Give me a sign if I'm not missing anything. Maybe we can cooperate in working out the solution.

Cheers and thx again

btw. support for fetching multiple docs by id will be possible easily

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant