hey guys i am new to mongo db
we are using mongo db for recording candlestick information with timeseries collection
but we want to avoid duplicate data
i created a time series collection:
db.createCollection(
"timeseries_5",
{
timeseries: {
timeField: "timestamp",
metaField: "symbol",
granularity: "seconds"
}
}
)
i created my index
db.timeseries_5.createIndex(
{
"timestamp": 1,
"symbol": 1
},
{
name: "symbol_timestamp",
sparse: true
}
);
but i can pass unique:true
{
"message" : "Unique indexes are not supported on collections clustered by _id",
"ok" : 0,
"code" : 72,
"codeName" : "InvalidOptions"
}
how i avoid duplicate data in mongo db timeseries collection???
i need unique 2 field (symbol, timestamp)
this is how i insert my data
db.timeseries_5.insert([{
timestamp: ISODate('2019-01-01T13:15:00.000Z'),
symbol: 'SNX',
metadata:{
open: 0.040613,
high: 0.040613,
volume: 3286.08613337,
close: 0.040123,
exchange: 'kucoin',
low: 0.039847,
}
}])