System Information
- 4.1.5:
- Windows:
- Postgres:
I have a lifestyle hook like so for articles to track views
module.exports = {
async afterFindOne(event) {
if (event) {
const { result } = event;
const currentViews = parseInt(result.views);
const newView = currentViews+1
strapi.query("api::article.article").update({
where: { id: result.id.toString() },
data: {
views: newView,
},
});
}
},
};