V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
thomaswang
V2EX  ›  问与答

请教 gorm 问题

  •  
  •   thomaswang · 2018-11-21 10:56:59 +08:00 · 923 次点击
    这是一个创建于 1976 天前的主题,其中的信息可能已经有所发展或是发生改变。
    // 重设列名
    type Animal struct {
        AnimalId    int64     `gorm:"column:beast_id"`         // 设置列名为`beast_id`
        Birthday    time.Time `gorm:"column:day_of_the_beast"` // 设置列名为`day_of_the_beast`
        Age         int64     `gorm:"column:age_of_the_beast"` // 设置列名为`age_of_the_beast`
    }
    
    // 使用 tag`primary_key`用来设置主键
    type Animal struct {
      AnimalId int64 `gorm:"primary_key"` // 设置 AnimalId 为主键
      Name     string
      Age      int64
    }
    

    如果需要给一个字段 重设列名 & 设置主键 该咋写?

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5352 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 03:39 · PVG 11:39 · LAX 20:39 · JFK 23:39
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.