[GODRIVER-972] add IsDuplicateKey(err) helper Created: 17/Apr/19 Updated: 02/Dec/20 Resolved: 02/Dec/20 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Sam Kleinman (Inactive) | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 4 |
| Labels: | evg, mgocompat, neweng, rp-track | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Epic Link: | GODRIVER-114 | ||||||||||||
| Description |
|
This would be equivalent to MGO's "IsDup" and provide a simple way to handle duplicate key issues. I think the implementation would look something like this:
|
| Comments |
| Comment by Ed Pelc [ 01/Dec/20 ] |
|
Just FYI you need to check for WriteException(regular UpdateOne, UpdateMany, Insert*, etc), BulkWriteException(bulk variants), and CommandError(can be returned from FindOneAndUpdate). |
| Comment by Ian Whalen (Inactive) [ 18/Apr/19 ] |
|
might want to make this a helper on the individual write error. |