I’m looking for the most practical approach to content tree modeling in Contentful. The content tree I’m envisioning is this:
I want to structure this in a way that:
- I can send a
GETrequest to find out which Region/Country/States/Cities have the most blog posts
- I can list all articles under a specific Region/Country/State/City with the least amount of API calls
- I can list all states in a region, or all countries in a region, etc.
I’ve currently set up content types for each of them with a reference field. Each city (Berlin, San Francisco, etc) would have a reference field that links to a country (California, Germany, etc). This pattern continues up the chain. Each of these taxonomy terms have additional fields, such as
When I create a new entry under a taxonomy term, I simply add to the
entry_count field for each of them respectively. When an entry is removed, I subtract.
It works, but there are margins for error since I have to programmatically adjust each taxonomy term every time a new entry is added. It also feels very messy and feels more like a hack.
Is there a better approach than this?