First of all, thank you for your answers John_Sewell and Steeve.
Finally I decided to use aggregations. I thought that the modifications made by $set operator modifying matching documents after a $match pipeline were persisted in the database. It was just my lack of knowledge about aggregations. This method solved my problem.
Thank you very much and I hope this is useful for anyone having the same doubt!
1 Like