How do you use the $inc operator with a field with a dot in the key
here’s what i have tried
const filter = { _id :1 }
const update = {
$inc: {
'ratings.1': 1,
'ratings.2.5': 2
},
}
const options= { upsert:true}
return await db.collection('ratings').update(
filter,update,options
)
the result i get in database
{
id:1,
ratings: {
1: 1,
2: { 5: 2 }
}
}
what i want is
{
id:1,
ratings: {
1: 1,
2.5: 2
}
}