I want to add a new value to a string array in postgres db using go-pg. How could I push a new value to the array using go-pg.
This is my user model
type User struct {
ID string `pg:"id,notnull,unique" json:"id"`
Email string `pg:"email,notnull,unique" json:"email"`
Skills []string `pg:"skills,array" json:"skill"`
}
I want to update the skills array whenever user adds a new skill using the userid.
Data from client contains the userid and a single skill selected by the user.
In go-pg we can update a column in the following way
pg.Model(user).Set("data = ?data").Where("id = ?id").Update()
But how could I push a new data to the array?
As Yun Luo suggested I have done with
array_append.