Join the Webstudio community

Updated 2 months ago

Nested collections

At a glance

The community member is trying to group their Airtable data into production batches so that customers can see the status of their orders. They tried setting up nested collections, but couldn't find a way to only fetch the orders under each batch. Instead, they were able to fetch all orders under each batch and then hide the ones that didn't have the batch as an Airtable lookup field.

In the comments, another community member suggests that the "show/hide" approach is done on the server, so it's a quick and light operation. They propose two options: 1) Get all the data and show/hide, or 2) Have the data served up in groups, with one table for batches and another for orders, and use a lookup column to select the batches. The community member ultimately went with the first option and found that it loaded okay.

Hi

I want to group my data from Airtable. I am trying to make a public production plan, so that customers can see status of their order.

Each of these records in the attached screenshots are orders in the production plan. I want to group them for each production batch.

I tried to set up nested collections, so that the first Collection is the batch and the the second Collection is the order. But I can't find a way to only fetch the orders that is under each batch.

I am able to fetch all Orders under each Batch, and then hide the ones that do not have this Batch as a Airtable lookup field.

What is the smartest way to group collection items? Am I approaching it all wrong? Any help is appreciated πŸ™‚

Best, Malthe
J
M
5 comments
Always a little tricky to chime in on this stuff because it takes me a bit to wrap my head around the data models, but this statement:

I am able to fetch all Orders under each Batch, and then hide the ones that do not have this Batch as a Airtable lookup field.

...sounds accurate. Does that not work for you?
Hi. Thank you for your reply!

To sum it up, I just want to group my records from Airtable by a category.

Regarding this:

"I am able to fetch all Orders under each Batch, and then hide the ones that do not have this Batch as a Airtable lookup field."

Doesnt the site then becoming very heavy? Will Webstudio load all the data for the ones that is hidden also?
The show/hide is done on the server so its a very quick and light operation.

I see two options

  1. Get all of them and show/hide
  2. Have them served up in their groups. Eg table 1 has all batches and table 2 has all orders. The in table 1 you add a lookup column and select each of the batches. If the data is served how I think it should, then you get exactly what you need. Idk the impact this would have on your editorial workflows though
Maybe in the builder it can become sluggish but it depends on how many records we are talking about
Thank you! Good to know that is done on the server. I went with option 1 it loads okay πŸ™‚
Add a reply
Sign up and join the conversation on Discord