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

Subcollection support #7

Open
DB-Alex opened this issue Jan 14, 2020 · 7 comments
Open

Subcollection support #7

DB-Alex opened this issue Jan 14, 2020 · 7 comments
Labels
enhancement New feature or request

Comments

@DB-Alex
Copy link

DB-Alex commented Jan 14, 2020

Is subcollection support on your road map?

Like here:
https://www.gatsbyjs.org/packages/@martinreiche/gatsby-firestore/

@deanc
Copy link
Owner

deanc commented Jan 14, 2020

Not currently thought about this @alexvandervegt - as I've not used sub-collections in Firestore myself. Can you give an example and how you'd want to use it in firestore?

It shouldn't be a huge problem lifting the code from martin's repo and integrating it here.

@deanc deanc added the enhancement New feature or request label Jan 14, 2020
@DB-Alex
Copy link
Author

DB-Alex commented Jan 15, 2020

Hi @deanc,

I like to keep my data together. For example, I have page large landing page which contains about 40 components. Its to big to store it in a firestore array type.

Then I use a structure like this:

  • pages
    • blocks

So blocks is a subcollection of the current page containing all the data about the components used on that specific page.

If you are thinking about integrating the code of martin's repo, can you please give me a timeframe for it?

Many thanks in advance!

@deanc
Copy link
Owner

deanc commented Jan 16, 2020

@alexvandervegt are you sure Martin's code doesn't work? I took a little bit of it and tried it out locally and I have an allBlock and allSpecialpage node's in the graphql explorer for these types:

types: [
          {
            type: "Specialpage",
            collection: "pages",
            map: doc => ({
              ...doc,
            }),
            subCollections: [
              {
                type: `Block`,
                collection: `blocks`,
                map: doc => ({
                  name: doc.name,
                }),
              },
            ],
          },

You should expand the allBlock and view the parent for each of them as that will allow you to link back to the necessary page node yourself.

@DB-Alex
Copy link
Author

DB-Alex commented Jan 21, 2020

Ended up creating my own source plugin. Thanks for your quick replies though!

@DB-Alex DB-Alex closed this as completed Jan 21, 2020
@deanc
Copy link
Owner

deanc commented Jan 21, 2020

Hi @alexvandervegt - maybe you'd like to contribute back to this repo with a PR to add the feature?

@DB-Alex
Copy link
Author

DB-Alex commented Jan 21, 2020

Its a whole other structure, i will post it to gatsby plugins myself when its finished

Repository owner deleted a comment from DB-Alex Jan 25, 2020
Repository owner deleted a comment from DB-Alex Jan 25, 2020
Repository owner deleted a comment from DB-Alex Jan 25, 2020
Repository owner deleted a comment from DB-Alex Jan 25, 2020
@deanc
Copy link
Owner

deanc commented Jan 25, 2020

Opening this again. I made a PR, and will leave it here for future users who may want this feature.
#8

@deanc deanc reopened this Jan 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants