Join the Webstudio community

Updated 3 months ago

Displaying nested collection Baserow -> WS

At a glance

The community member has connected Webstudio (WS) with Baserow, where there are "Categories" and "Subcategories" tables linked to each other. The community member wants to display the "Subcategories" for each "Category" in WS, but the lookup field only returns the "Subcategory" name and ID, not the slug. The community member sees two potential solutions: create a lookup field for "Subcategory" slugs, or create a combined string field in Baserow with the "Category" name and slug. Another community member suggests joining the fields in the WS query and iterating through the collection, which the original community member confirms is exactly what they were looking for. There is no explicitly marked answer, but the community members discuss potential performance considerations with the suggested solution.

Useful resources
I have connected WS with Baserow. Imagine in Baserow there are tables "Categories" and "Subcategories" that are linked each other. "Categories" have a lookup field that shows the array of "Subcategories"
On WS I am getting the "Caregories" and I want to show the "Subcategories" for each "Category". I can get that array field but it only returns the lookup value (e.g. name of "Subcategory") and the "Subcategory" ID.

My goal is to also get the slug of that "Subcategory". I see two ways solving this:
  1. Create another lookup field that displays the "Slugs" array for the "Subcategories". The problem is that I cannot find a way to iterate in WS (e.g. getting an index and display the values from those two fields based on the index)
  2. Create a string field in Baserow combing the two fields with a separator, e.g. "{category_name} | {category_slug}". Then it is easy to fetch it in WS, but I would need to split the two values out of the string. Is this possible in WS?
Or is there a better way to approach it?

Thanks in advance!
J
c
4 comments
I have this column which i think is the same as you. And in my query I add this &field_2998685__join=field_2998661,field_2998684,field_3004070 Which adds fields from the other table. So you can add your slug in there
And iterate with a collection
Awesome! This is exactly what I was looking for, thanks @John Siciliano πŸ‘

I wonder if there may be performance/speed considerations by joining tables via the api
Seems fine πŸ€·β€β™‚οΈ This feature will be a really nice addition https://github.com/webstudio-is/webstudio/issues/4077
Add a reply
Sign up and join the conversation on Discord