How to Prevent updatedAt from Changing on Specific PUT API Calls in Strapi

I’m working on a project using Strapi and I’ve encountered an issue with the updatedAt timestamp. I have a collection item that includes a viewCount attribute. Every time the viewCount is incremented via a PUT API call, the updatedAt timestamp is also updated. However, I want to avoid updating the updatedAt timestamp when only the viewCount is changed via the API. It should still be updated when other attributes are changed either via the API or the admin panel.

Does anyone know the best way to achieve this in Strapi?
Any help or guidance would be greatly appreciated!

This topic has been created from a Discord post (1263781498696499276) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

I found a way by creating lifecycles.js :

module.exports = {
  async beforeUpdate(event) {
    const { data, where } = event.params;
    if (data.viewCount !== undefined) {
      const entry = await strapi.entityService.findOne('api::game.game', where.id, { fields: ['updatedAt'] });
      data.updatedAt = entry.updatedAt;
    }
  },
};