Hello,
I want to save views of articles/posts in strapi as a simple integer value.
Do you know an approach how to have something like a view counter in strapi? So every time an articles is viewed in the client an counter should increment. Do you know a solution for this?
I want to get the most viewed articles - so I think I need this value.
My thought was to use lifecycle hooks for this. But which one is the right (maybe afterFindOne, but I’m not sure)? And how can I update the the data in the afterFindOne-hook? I seen an example for the beforeCreated-hook, but in this hook I have the data of the model/entity.
And another question: When an afterFindOne-hook should be a solution, will this hook be called when I query data with graphql or just for the rest api call?
Thanks for some help with this!
Best regards,
Timo