Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-46055

Error: the update operation document must contain atomic operators

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 4.2.0
    • Component/s: Write Ops
    • None
    • Fully Compatible
    • ALL
    • Hide

      Was testing for something & found this issue, So tried to execute what's given in documentation https://docs.mongodb.com/manual/reference/method/db.collection.updateMany/index.html#examples

      So when executing aggregation pipeline in updateMany() getting this error every time on v4.2, Tried this on robo3T & mongo shell result is same. 

      Query : (Same as given in documentation)

       

      Insert :

       

      db.members.insertMany([

      { "_id" : 1, "member" : "abc123", "status" : "A", "points" : 2, "misc1" : "note to self: confirm status", "misc2" : "Need to activate", "lastUpdate" : ISODate("2019-01-01T00:00:00Z") },
       { "_id" : 2, "member" : "xyz123", "status" : "A", "points" : 60, "misc1" : "reminder: ping me at 100pts", "misc2" : "Some random comment", "lastUpdate" : ISODate("2019-01-01T00:00:00Z") }
      ])

       

      Update :

      db.members.updateMany(
       { },
       [
       { $set: { status: "Modified", comments: [ "$misc1", "$misc2" ], lastUpdate: "$$NOW" } },
       { $unset: [ "misc1", "misc2" ] }
       ]
      )

      Working code (works with update) :

       
       

      db.members.update({}, [{ $set: { status: "Modified", comments: ["$misc1", "$misc2"], lastUpdate: "$$NOW" } }, { $unset: ["misc1", "misc2"] }], false, true)

       

      Show
      Was testing for something & found this issue, So tried to execute what's given in documentation https://docs.mongodb.com/manual/reference/method/db.collection.updateMany/index.html#examples So when executing aggregation pipeline in updateMany() getting this error every time on v4.2, Tried this on robo3T & mongo shell result is same.  Query : (Same as given in documentation)   Insert :   db.members.insertMany([ { "_id" : 1, "member" : "abc123" , "status" : "A" , "points" : 2, "misc1" : "note to self: confirm status" , "misc2" : "Need to activate" , "lastUpdate" : ISODate( "2019-01-01T00:00:00Z" ) }, { "_id" : 2, "member" : "xyz123" , "status" : "A" , "points" : 60, "misc1" : "reminder: ping me at 100pts" , "misc2" : "Some random comment" , "lastUpdate" : ISODate( "2019-01-01T00:00:00Z" ) } ])   Update : db.members.updateMany( { }, [ { $set: { status: "Modified" , comments: [ "$misc1" , "$misc2" ], lastUpdate: "$$NOW" } }, { $unset: [ "misc1" , "misc2" ] } ] ) Working code (works with update) :     db.members.update({}, [{ $set: { status: "Modified" , comments: [ "$misc1" , "$misc2" ], lastUpdate: "$$NOW" } }, { $unset: [ "misc1" , "misc2" ] }], false , true )  

      Getting 'Error: the update operation document must contain atomic operators' when executing aggregation pipeline thru .updateMany() on v4.2

            Assignee:
            dmitry.agranat@mongodb.com Dmitry Agranat
            Reporter:
            vtxn0504@gmail.com srinivas yalamanchili
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: