Details
-
Improvement
-
Resolution: Done
-
Minor - P4
-
None
-
None
-
None
-
debian 7 (Wheezy) mongodb 2.4.10
Description
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.