How to prevent duplicates in mongodb timeseries collection

Hello everyone,

Anyone find a better solution for this issue?