[SERVER-14345] Give driver additional details on $pull Created: 24/Jun/14 Updated: 10/Dec/14 Resolved: 24/Jun/14 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Daryl Tucker | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | $pull | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
debian 7 (Wheezy) mongodb 2.4.10 |
||
| Participants: |
| 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.
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. |
| Comments |
| Comment by Bernie Hackett [ 24/Jun/14 ] | ||||
|
Great! Let us know if you run into any other issues. | ||||
| Comment by Daryl Tucker [ 24/Jun/14 ] | ||||
|
Thank you for your patience and clarification. I have updated to mongo version `2.6.1` (after realizing the packages changed from *-10gen* to *-org*). You are absolutely correct that 'nModified' is returned with this version and that it reflects whether or not the document has been changed/modified.
| ||||
| Comment by Bernie Hackett [ 24/Jun/14 ] | ||||
|
I think MongoDB 2.6 may do what you want. It returns an nModified field with a count of the documents that were actually modified: http://docs.mongodb.org/manual/reference/command/update/#update-specific-fields-of-one-document An example in python using your example document:
| ||||
| Comment by Bernie Hackett [ 24/Jun/14 ] | ||||
|
The python driver is just returning the raw result from the server. The server itself would have to return the field you are asking for. | ||||
| Comment by Daryl Tucker [ 24/Jun/14 ] | ||||
|
I appologize for the horrible formatting. I was attempting to use Markdown and I see no way to edit for clarity. |