My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Design approach for counting friends unique category counts

Bujji's photo
Bujji
·Jan 25, 2019

In the below Index , Friends and all categories are numeric arrays . I can have up to 5000 friends and categories also arrays and they can have max 15 for each category . If I have 5000 friends and If my one of the category changes ( for example category 1 changes ) I have to count "Friends Category1 counts" for my all 5000 friends and update their counts .

bd8e6ba1bf50f7378915e81cb5de3f211ab7babb.png

Is there any way I can use Painless script and do it with one call ..? Or please guide me the best approach to handle this case

I use Nodejs for my backed . Thank You