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

findAndModify 2.2 Release Notes Unclear on the Command's Response

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None

    Description

      http://docs.mongodb.org/manual/release-notes/2.2/#findandmodify-returns-null
      http://docs.mongodb.org/manual/reference/command/findAndModify/

      Behavior outlined is incorrect... claims null returned always (or the odd ok: 1.0 hash), but this isn't the case and the correct behavior is more akin to what one would expect.

      > db.t.findAndModify({query:

      {name: "Steve"}

      , upsert: true, update: {name: "John"}})
      null
      > db.t.findAndModify({query:

      {name: "John"}

      , upsert: true, update: {name: "Johnny"}})

      { "_id" : ObjectId("50eb188773015b3832f64dda"), "name" : "John" }

      > db.t.findAndModify({query:

      {name: "Tyler"}

      , new: true, upsert: true, update: {name: "Johnny"}})

      { "_id" : ObjectId("50eb18e473015b3832f64ddc"), "name" : "Johnny" }

      >

      Attachments

        Activity

          People

            sam.kleinman Sam Kleinman (Inactive)
            spf13 Steve Francia
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              11 years, 6 weeks, 2 days ago