How to prevent duplicates in mongodb timeseries collection

What is wrong with upsert?