[SERVER-10958] Provide _id and error for failed document from multi-update Created: 30/Sep/13  Updated: 11/Jul/16  Resolved: 08/Oct/13

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: None
Fix Version/s: 2.5.3

Type: Improvement Priority: Major - P3
Reporter: jayakrishnan Assignee: Scott Hernandez (Inactive)
Resolution: Done Votes: 0
Labels: error-messages, getlasterror
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu 12.04 LTS 64 bit


Issue Links:
Related
related to SERVER-6399 Refactor update() code Closed
Participants:

 Description   

When i do update operation with more than one condition, if condition fails i can check whether update succeded or failed using getLastError.
But i can not get which condition failed. If mongodb provides, this will be helpful for my application.



 Comments   
Comment by auto [ 08/Oct/13 ]

Author:

{u'username': u'scotthernandez', u'name': u'Scott Hernandez', u'email': u'scotthernandez@gmail.com'}

Message: SERVER-10958: Update error messages and provide _id of error docs
Branch: master
https://github.com/mongodb/mongo/commit/4b5cfc190c702aad25a353d8b3e275f71599b05f

Comment by Scott Hernandez (Inactive) [ 03/Oct/13 ]

Okay, then this isn't really what you are asking for.

Please ask your question about your language/driver on the mongodb-user forum (https://groups.google.com/group/mongodb-user) as that is where you are going to get a typed exception or error message you can act on in your application code. If you are calling getLastError manually you should be using a write concern instead in your application code.

Comment by jayakrishnan [ 02/Oct/13 ]

I am developing a application for project management tool (web app) . I have a collection of "projects".Following is a document which represents a project
{
_id: <project id>,
name: <project-name>,
owner: <owner-id>
}
In my app project owner can update the name of a project.
User id can be obtained from session.
Here i will update like

db.update({_id:"projectId", owner: "userId"}, {"$set": {"name": "new-name"}});

update can be failed due to wrong _id or unauthorized access.
I have to return proper error message based on the above scenario.

I am not talking about multi update.

Comment by Scott Hernandez (Inactive) [ 30/Sep/13 ]

@jayakrishnan , I've updated this to be what I think you were asking for, which is how to find the document which caused the update failure. Please add an example if you have one so we can confirm this is what you want, and if possible please provide an example of what you want to see as an error.

Generated at Thu Feb 08 03:24:29 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.