i have a page with a table that displays the following columns:
| Name | date | student count | staff count | category |
I have queried the school collection which works fine but the issue is the student and staff count, I'm not sure how to tackle this scenario. Initially what I did was creat two fields integer for the school document which would hold the counts but that would mean the count would have to be done somewhere else. I was thinking may every time I add a staff or student while creating the user document I could update the school field as well with an increment but the issue would be if a student is removed the count will be compromised. The obvious solution was to make both fields ref documents to the user fields but the question now is how do I get the counts from the reference documents?