Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-972

add IsDuplicateKey(err) helper

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major - P3
    • Resolution: Duplicate
    • None
    • None
    • None

    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:

      func isMongoDupKey(err error) bool {
        wce, ok := err.(mongo.WriteConcernError)
        if !ok {
                return false
        }
        return wce.Code == 11000 || wce.Code == 11001 || wce.Code == 12582 || wce.Code == 16460 && strings.Contains(wce.Message, " E11000 ")
      }

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              sam.kleinman Sam Kleinman (Inactive)
              Votes:
              4 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: