I've been working on a project that involves using Mongoose to write, update, and perform other operations in a MongoDB database.
Currently, I am utilizing the updateOne() function within my own custom function. However, I am facing an issue where if I use
const resp = await seasonFixturesModel.updateOne({season_id: season_id, "fixtures.274704.id": 18535224},{$set:{"fixtures.274704.$":{} }});
with the hardcoded ID 274704, the update works correctly. Yet, I want to dynamically change this ID based on a parameter in my function, like so:
function updateMyDatabase(round_id: number){
const resp = await seasonFixturesModel.updateOne({season_id: season_id, "fixtures.round_id.id": 18535224},{$set:{"fixtures.round_id.$":{} }});
}
Can anyone provide guidance on how to achieve this? I have experimented with different solutions such as "fixtures.round_id.id", "fixtures.{round_id}.id", and "fixtures.${round_id}.id", but none seem to be effective.