Open DB-Alex opened 4 years ago
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.
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:
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!
@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.
Ended up creating my own source plugin. Thanks for your quick replies though!
Hi @alexvandervegt - maybe you'd like to contribute back to this repo with a PR to add the feature?
Its a whole other structure, i will post it to gatsby plugins myself when its finished
Opening this again. I made a PR, and will leave it here for future users who may want this feature. https://github.com/deanc/gatsby-source-firestorer/pull/8
Is subcollection support on your road map?
Like here: https://www.gatsbyjs.org/packages/@martinreiche/gatsby-firestore/