On mongodb Updating the Contents of All Objects in an Array

  mongodb, question

The documents are as follows:

name: 4,
 list: [
 {
 id: “a”,
 date: 1504195200000,
 other: “c”
 },
 {
 id: “b”,
 date: 1504195200000,
 other: “c”
 }
 ]
 }

How to update all other elements in the list array at one time?
I tried the following methods: no …

db.getCollection(‘test’).update({‘name’: 4}, {$set: {‘list.$.other’: ‘a’}}, {multi: true})

I don’t know why. Pray for a great god’s solution, thank you.

This method is supported from MongoDB 3.6, refer to the documentation:$ [] operator
3.6 Some enhancements have been made to array operations. Refer to the documentation for other operations on arrays:Array Update Operators