- Postgres
tsvector
type definition for Go - Tested to work with
database/sql
and GORM - Compatible with any driver respecting the
Scanner
andValuer
interfaces.
var out tsvector.TSVector
_ = sqlDB.QueryRow("SELECT $1::tsvector", "The quick brown fox jumps over the lazy dog").Scan(&out)
var out tsvector.TSVector
_ = sqlDB.QueryRow("SELECT to_tsvector($1)", "The quick brown fox jumps over the lazy dog").Scan(&out)
type MyModel struct {
ID int64 `gorm:"primaryKey"`
TSV tsvector.TSVector `gorm:"not null"`
}
in := &MyModel{
TextTSV: tsvector.ToTSVector("The quick brown fox jumps over the lazy dog"),
}
_ = gormDB.Create(in)
var out MyModel
_ = gormDB.First(&out, in.ID)