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

kumarsiva07 picture kumarsiva07  路  3Comments

bramp picture bramp  路  3Comments

izouxv picture izouxv  路  3Comments

zeropool picture zeropool  路  3Comments