I am attempting to use mongo findAndUpdate to update multiple documents and keep receiving syntax error:
db.forecasts.findAndModify({
query: {forDate: ISODate("2016-02-25T05:00:00.000+0000")},
update: {
{ $set: {forDate: ISODate("2016-02-23T05:00:00.000+0000")}},
{multi: true}
}
})
Alternately I also tried:
db.forecasts.update({
{'forDate': ISODate("2016-02-25T05:00:00.000+0000")},
{'forDate': ISODate("2016-02-23T05:00:00.000+0000")},
{multi: true}
})
The error I receive is :
Error at line 2 position 3: <missing ')
'
findAndModify()
doesn't allow {multi: true}
. You can only update one document and it returns the original doc (default) or uou can ask for thr updated doc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With