Update Many using $(update)

Viewed 55
db.getCollection('test').updateMany(
    {}, //match all
    [{
        $set: {
            players: {
                $concatArrays: [
                    [], //Creating new array for all the documents
                    [{ //Adding these values
                        "player_name": "$player_name",
                        "book_id": new ObjectId()
                    }]
                ]
            }
        }
    }]
)

When I try to do updateMany on this, it throws syntax error on $set braces.

Is it not possible with mongo version 4.2.8?

0 Answers
Related