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

Give driver additional details on $pull

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Environment:
      debian 7 (Wheezy) mongodb 2.4.10

      I understand why one would appreciate $pull success whether or not the item was actually pulled (since the effect is the same), but it would be nice to be able to determine if something was removed/if the document was changed.

          > db.test.findOne({})
          {
                  "_id" : ObjectId("53a9e45a9593e7fb44ad0aae"),
                  "credits" : [
                          "11111",
                          "22222",
                          "33333"
                  ]
          }
      
          >>> x = db.test.update({'_id': ObjectId("53a9e45a9593e7fb44ad0aae")},{'$pull': {'test': '2222'}})
          >>> x
          {u'updatedExisting': True, u'connectionId': 7, u'ok': 1.0, u'err': None, u'n': 1}
          >>> x = db.test.update({'_id': ObjectId("53a9e45a9593e7fb44ad0aae")},{'$pull': {'test': '2222'}})
          >>> x
          {u'updatedExisting': True, u'connectionId': 7, u'ok': 1.0, u'err': None, u'n': 1}
      

      If some field:value could be added, such as

      {'documentChanged': True}

      , then one could programmatically determine if a $pull query has made any modifications to the document.

            Assignee:
            Unassigned Unassigned
            Reporter:
            daryltucker Daryl Tucker
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: