I have a collection called Names with a document that looks like this:
{
"_id":33,
"listOfNames" : ["John", "Fred", "Andy"]
}
I am trying to do an update command that looks like the following:
db.Names.update{{}, {$set: {"listOfNames" : ["John", "Mary"]}, {multi:true})}
This fails with "unexpected token". What is the correct syntax to use when updating a field in a series of documents when the field is an array?
use this query
db.Names.update({},
{
$set: {"listOfNames":["John", "Mary"]},
}, { multi : true })
{
after update function, You should use (
)
in wrong place
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.