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

Clarify documentation for the 'n' value of the result from update

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Icon: Minor - P4 Minor - P4
    • Server_Docs_20231030
    • None
    • manual, Server
    • None

    Description

      The documentation for the output of update is incomplete about the value of update.n.

      In particular, the value of update.n will also include any upserted documents in addition to documents, which were matched.

      Here is the actual value from upserting into an empty collection:

      MongoDB shell version: 3.2.0-rc2-97-g243188c
      connecting to: test
      > use Test;
      switched to db Test
      > var res = db.runCommand({ update: 'TestColl', updates: [ { q: { _id: 1 }, u: { _id: 1, value: 5 }, upsert: true } ] });
      > res
      {
              "ok" : 1,
              "nModified" : 0,
              "n" : 1,
              "upserted" : [
                      {
                              "index" : 0,
                              "_id" : 1
                      }
              ]
      }
      

      Attachments

        Activity

          People

            kay.kim@mongodb.com Kay Kim (Inactive)
            kaloian.manassiev@mongodb.com Kaloian Manassiev
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              1 year, 14 weeks, 1 day ago