首页 > 其他 > 详细

Tips on GORM, Avoid Error about "duplicate column name: id"

时间:2018-04-15 20:31:12      阅读:351      评论:0      收藏:0      [点我收藏+]

The GORM is an super easy ORM solution for Go language.

But many people would get the error about 

duplicate column name: id

Usually this comes from the model definition which has duplicated ID,

package model

import (
    "github.com/jinzhu/gorm"
)

type Job struct {
    gorm.Model // Already has ID, CreatedAt, UpdatedAt, DeletedAt 4 fields
    Name string
}

We could remove the ID definition from our code and only use the one from grom.Model, or don‘t use the gorm.Model at all.

Tips on GORM, Avoid Error about "duplicate column name: id"

原文:https://www.cnblogs.com/Jedimaster/p/8849013.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!