【问题标题】:Define tsvector type column for a model为模型定义 tsvector 类型列
【发布时间】:2018-05-31 16:52:15
【问题描述】:

我想通过在模型结构中定义一个字段来在 postgres 中添加 tsvector 类型的列。它看起来有点像:

type Issue struct {
  ...
  TSV tsvector `json:"tsv"`
}

原因是我想使用 gorm 的AutoMigrate 在开发时保持表格最新。有什么想法吗?

【问题讨论】:

    标签: go go-gorm


    【解决方案1】:
    type Address struct {
        TSV string         `gorm:"type:tsvector"`
    }
    

    也可以参考https://github.com/jinzhu/gorm/blob/master/dialects/postgres/postgres.go,应该和hstore、jsonb类似

    【讨论】:

    • 谢谢。我建议进行编辑,以使答案与问题的特殊性更相关。
    猜你喜欢
    • 2011-02-08
    • 1970-01-01
    • 2019-12-07
    • 1970-01-01
    • 2014-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-20
    相关资源
    最近更新 更多