1 year ago
#354909

Gabriel Faria
How to substitute $ for a parameter in Array Update Operators [Mongoose]
I have an apparently simple question, is it possible for me to replace the $ operator used to identify the index of an attribute array inside the mongoose for a variable that I have already passed as a parameter?
i.e. transform
$set: {"img.$]": req.params.imgUrl}
into something like
const indexDesired = req.params.indexParams // 0, 1 , 2
$set: {"img.indexDesired]": req.params.imgUrl}
thanks in advance for any and all help!
javascript
node.js
arrays
mongoose
operator-keyword
0 Answers
Your Answer