Gorm: Error type of duplicate unique key

Created on 17 May 2016  路  2Comments  路  Source: go-gorm/gorm

Like the title says, I want to catch the error if a user is sending already taken email. Is there any easy function like mgo.IsDup() from mgo?

All 2 comments

Yes check the error string returned when there is an constraint violation and do a strings.contain( foe the error code and the name of violated constraint.

Ah, nice insight. Thank you again.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pjebs picture pjebs  路  3Comments

alanyuen picture alanyuen  路  3Comments

corvinusy picture corvinusy  路  3Comments

rfyiamcool picture rfyiamcool  路  3Comments

superwf picture superwf  路  3Comments