Created
August 21, 2020 09:18
-
-
Save Marvin9/4cafaab9741145e73d4232db05cb4fe6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package database | |
import ( | |
"github.com/jinzhu/gorm" | |
) | |
// Users - | |
type Users struct { | |
gorm.Model | |
Username string | |
} | |
// AddUser - | |
func AddUser(username string) error { | |
db, err := ConnectDB() | |
if err != nil { | |
return err | |
} | |
defer db.Close() | |
db.AutoMigrate(&Users{}) | |
err = db.Create(&Users{ | |
Username: username, | |
}).Error | |
if err != nil { | |
return err | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment