Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>When updating the multiple documents in a single update command you must set the multiflag to true. As shown in your pymongo example it set to true already. But the log you have pulled shows no sign of multi flag. I believe thats the problem. </p> <p>Check out the below example executed in mongo shell with multi</p> <pre><code>&gt; db.posters.insert({_id:1,feed:[{_id:"4020800", object: "activity"}]}) &gt; db.posters.insert({_id:10,feed:[{_id:"4020800", object: "activity"}]}) &gt; db.posters.insert({_id:101,feed:[{_id:"4020800", object: "activity"}]}) &gt; db.posters.find() { "_id" : 1, "feed" : [ { "_id" : "4020800", "object" : "activity" } ] } { "_id" : 10, "feed" : [ { "_id" : "4020800", "object" : "activity" } ] } { "_id" : 101, "feed" : [ { "_id" : "4020800", "object" : "activity" } ] } </code></pre> <p>and</p> <pre><code>&gt; db.posters.update({ _id: { $in: [ 1, 10]}}, { $pull: { feed: { _id: "4020800", object: "activity" } } },false,true) &gt; db.posters.find() { "_id" : 1, "feed" : [ ] } { "_id" : 10, "feed" : [ ] } { "_id" : 101, "feed" : [ { "_id" : "4020800", "object" : "activity" } ] } </code></pre> <p>It works fine. So i believe there is a problem in the driver not the mongo. </p> <p>Also i dont believe that it works fine in your last example too</p> <blockquote> <p>I then logged into the shell and executed the update manually:</p> <pre><code>db.posters.update({ _id: { $in: [ "1", "10", "18537", "19778", "20137", "20967", "4", "54", "5835", "9" ] } }, { $pull: { feed: { </code></pre> <p>_id: "4020800", object: "activity" } } })</p> <p>I checked the affected records within the shell and it worked perfectly.</p> </blockquote> <p>Without multi flag it only updates the first item. below the sample</p> <pre><code>&gt; db.posters.update({ _id: { $in: [ 1, 10]}}, { $pull: { feed: { _id: "4020800", object: "activity" } } }) &gt; db.posters.find() { "_id" : 1, "feed" : [ ] } { "_id" : 10, "feed" : [ { "_id" : "4020800", "object" : "activity" } ] } { "_id" : 101, "feed" : [ { "_id" : "4020800", "object" : "activity" } ] } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload