Can’t you use an update with upsert:true?
Something along the way:
// Usual inserted document that produces duplicates
insert = { "sensor":1 ,
"timestamp":2 ,
"mesure":"pressure" ,
"value":10 }
// Modified into a query that would define you uniqueness
query = { "sensor" : 1 , "timestamp" : 2 , "mesure" : "pressure" }
// With the value
value = { "value":10 }
// Also replace the following insert that produces a new duplicate
// every time it is called
c.insert( insert ) ;
// into an update with upsert:true that will insert only once
// no matter how often it is called.
c.update( query , value , { upsert:true } )
I am not yet familiar with the new time series collections. I do not know if it is applicable or not. But I feel it could.