Is this possible at all? I’m using NextJS and graphql-request to get data from the CMS. Two of the models I’m have are:
- Areas
- Developments
Within the developments the client wants to assign them to an area. They do not want to use multiple links on an area. So I have a single link on each development record where they can choose one of the Area records.
Now this is fine when showing the area information on individual development pages on the front end, but there are also Area pages where we need to list all of the developments allocated to the area. On these I am looping through all developments and dividing the count meta by 100 in order to ensure I’ve checked everything (there are 800 records so far and the site is only growing).
On the home page we have all areas listed and a number showing how many developments are in each area. In order for me to do this, again, I am having to loop through count/100 and then for each development match its area to an area to count them and display how many exist.
I feel like it would be so much easier if we could just do something like looping through areas and then:
developments.filter(development => development.area.id === area.id)
to get the count / developments that have a link to the area.
Can it be done some way in NextJS?