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

Error: the update operation document must contain atomic operators

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Works as Designed
    • 4.2.0
    • None
    • 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 )  

    Description

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

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: