V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
imherer
V2EX  ›  Go 编程语言

gorm 如何使用 postgresql 中 schema 下的 table

  •  
  •   imherer · 2020-09-07 15:09:10 +08:00 · 1887 次点击
    这是一个创建于 1333 天前的主题,其中的信息可能已经有所发展或是发生改变。
    默认 gorm 时都是使用 db 下的 table,那如何使用 db 下 schema 中的 table 呢?
    2 条回复    2020-09-09 09:29:39 +08:00
    xifengzhu
        1
    xifengzhu  
       2020-09-08 11:52:57 +08:00
    默认应该是 public 这个 schema 中的 table,gorm 没看到支持这个方面的文档,可以去 github 提个问题。
    imherer
        2
    imherer  
    OP
       2020-09-09 09:29:39 +08:00
    @xifengzhu 谢谢

    之前在 GitHub 上看了下有人也提过类似的问题,jinzhu 的回答是通过 db.Table("schema.table") 这样的方式去解决

    看来目前只能这样了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2255 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 07:13 · PVG 15:13 · LAX 00:13 · JFK 03:13
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.