'Add new field from plugin to existing collection type in Strapi.js

I can't seem to find a proper way for my plugin to add a new field to existing collection types in Strapi.js.

What I need:

I need that upon install of the plugin a new field "votes" would be added to all the existing collection types. And endpoint would then be exposed to simply increase the numerical value of the "votes" by +1.

What I tried:

I tried creating a completely new, hidden collection called "votes", on POST request to a voting endpoint it would create a vote item with a reference to an existing collection item via uid and id. Then I would be able to count votes for an specific item by counting number of items in "votes" collection with a reference to the given item. This however seems like overengineering as in reality what I really need is to add a simple number to an item and then simply increase it by +1 everytime someone hits an endpoint.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source