[SERVER-514] Setting _id in upsert() operation that uses $set Created: 02/Jan/10 Updated: 02/Jan/10 Resolved: 02/Jan/10 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 1.2.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | gf | Assignee: | Eliot Horowitz (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
no matter |
||
| Participants: |
| Description |
|
I want to add object with CERTAIN _id if object doesn't exist. Else, I want to use $set on it's properties. > db.chatsessions.update( {"_id": "test"}, {"_id":"test"}, {upsert: true}); <_id": "test1"},{"_id":"test1","$set":{"key": "value"}}, {upsert: true}); ,{"$set":{"_id": "test1", "key": "value"}}, {upsert: true}); I think that the error "Modifiers and non-modifiers cannot be mixed" shouldn't occur in case of _id. |
| Comments |
| Comment by Eliot Horowitz (Inactive) [ 02/Jan/10 ] |
|
_id on the right is redundant. On upsert query and mod are automatically combined |