Give driver additional details on $pull

XMLWordPrintableJSON

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

      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
              Reporter:
              Daryl Tucker
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: