-
SQLite3 DB user.go package database
import (
"fmt"
"infohubserver/internal/utils"
"strconv"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"gorm.io/gorm"
)
type User struct {
//Main columns
UserId uint `gorm:"autoIncrement;primaryKey;not null;unique" json:"userId"`
UserFirstName string `gorm:"not null" json:"userFirstName"`
UserLastName string `gorm:"not null" json:"userLastName"`
UserInitial string `gorm:"not null" json:"userInitial"`
UserUsername string `gorm:"not null;unique;<-:create" json:"userUsername"`
UserPassword string `gorm:"not null" json:"userPassword"` //Encrypted password
UserRole string `gorm:"not null" json:"userRole"`
UserAvatarImg []byte `gorm:"default:NULL" json:"userAvatarImg"`
//For form submiting value or extra info only (Will not be recorded in database)
Password string `gorm:"-:all" json:"password"`
UserFullName string `gorm:"-:all" json:"userFullName"`
} Error: 2022/08/31 14:30:50 C:/Users/vho/go/pkg/mod/gorm.io/driver/[email protected]/migrator.go:416 near ")": syntax error
[0.000ms] [rows:0] INSERT INTO `users__temp`() SELECT FROM `users` When no existing Users table, I am not sure what causing Please help! |
Beta Was this translation helpful? Give feedback.
Answered by
KiddoV
Sep 1, 2022
Replies: 1 comment
-
NVM, I just figured it out. I have a confict column name. Gorm is generating "user_first_name " column, but my existing table has "user_firstname ". Added |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
KiddoV
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NVM, I just figured it out. I have a confict column name. Gorm is generating "user_first_name " column, but my existing table has "user_firstname ".
Added
gorm:"column:user_firstname"
tag!