Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-7599

Why does $set work differently with upsert?

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major - P3 Major - P3
    • Server_Docs_20231030
    • None
    • manual, Server

    Description

      db.products.update(
         { _id: 100 },
         { $set:
            {
              "tags.1": "rain gear",
              "ratings.0.rating": 2
            }
         },
         { upsert: true }
      )
      

      why with upsert option which perform insert operation in my case, getting different result?

      { "_id" : 100, "tags" : { "1" : "rain gear" }, "ratings" : { "0" : { "rating" : 2 } } }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            bakhtiyor.h node
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              1 year, 14 weeks, 2 days ago