-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Description
Error :
cannot scan redis.result 2023-01-31T17:08:37.0314813+05:30 into struct field User.Date_created of type time.Time, error-redis.Scan(unsupported time.Time)</b>
Version : github.com/redis/go-redis/v9 v9.0.0-rc.4
type User struct {
Id string `json:"id" gorm:"primaryKey;type:text" redis:"id"`
Username string `json:"username" gorm:"type:varchar(25);uniqueIndex;not null" redis:"username"`
Email string `json:"email" gorm:"type:varchar(40);uniqueIndex;not null" redis:"email"`
Password string `json:"password,omitempty" gorm:"type:varchar(50);not null" redis:"-"`
Date_created time.Time `json:"data_created" gorm:"type:timestamp" redis:"date_created"`
}
func (u *UserPostgresRepo) Create(user model.User) error {
result := u.db.Create(&user)
if result.Error != nil {
return result.Error
}
redis_key := "users:" + user.Username + ":metadata"
err := u.redis.HSet(
ctx, redis_key,
"id", user.Id,
"username", user.Username,
"email", user.Email,
"date_created", time.Now(),
)
if err.Err() != nil {
return err.Err()
}
return nil
}
yusuftaufiq
Metadata
Metadata
Assignees
Labels
No labels