Interesting phenomenon of updating two-dimensional array by Mongodb update operation

< H1 > problem description < / H1 >

has the following data:

WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })

this time the elements in this array are deleted correctly.

< H1 > final question < / H1 >

WHY?

is there a potential relationship between the query in the udpate operation and the following modification operation, or is it related to the condition in $pull?

Apr.08,2022

< H1 > answer < / H1 >

as I guessed, it's a matter of detail.

By default, the update () method updates a single document.

by default, update only modifies the first piece of data that matches.

in the statement I use:


rs0:PRIMARY> db.test.insert({ "_id" : 2, "name" : "li", "favorites" : [ "apples", "pudding", "pie", "cake", [ "cake" ] ] })
rs0:PRIMARY> db.test.update({},{$pull:{favorites:{$in:[['cake']]}}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
rs0:PRIMARY> db.test.find()
{ "_id" : 2, "name" : "li", "favorites" : [ "apples", "pudding", "pie", "cake" ] }

it seems that I can't reproduce the problem. What's your version?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c02b0a-32615.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c02b0a-32615.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?