Hi there,
I am using the $set update operator with $[] positional operator to target a nested array item. In the following -
$set: {
'doctors.$[a].patients.$[b].medication.$[c].scriptNotes.1': scriptNotesDetail,
}
… can the index value ‘1’ (for field scriptNotes.1) be a dynamic variable? For example, if const indexValue = 3
, can I somehow reference the variable indexValue
in place of the hardcoded ‘1’? I would like to use an index value not a field value.
Hope that makes sense. Many thanks for your help.