Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go-gin-example/models/tag.go 18行发现一个问题 #41

Closed
jinnzy opened this issue Feb 20, 2019 · 1 comment
Closed

go-gin-example/models/tag.go 18行发现一个问题 #41

jinnzy opened this issue Feb 20, 2019 · 1 comment

Comments

@jinnzy
Copy link

jinnzy commented Feb 20, 2019

大佬下面的 err := db.Select("id").Where("name = ? AND deleted_on = ? ", name, 0).First(&tag).Error
应该是db.Select("name")吧?
func ExistTagByName(name string) (bool, error) {
var tag Tag
err := db.Select("id").Where("name = ? AND deleted_on = ? ", name, 0).First(&tag).Error
if err != nil && err != gorm.ErrRecordNotFound {
return false, err
}

if tag.ID > 0 {
	return true, nil
}

return false, nil

}

@jinnzy jinnzy closed this as completed Feb 20, 2019
@jinnzy
Copy link
Author

jinnzy commented Feb 20, 2019

看错了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant