Storing an array of strings in postgresDB using golang gorm

56 views Asked by At

I am using golang gorm and Postgres in my project. I need to store the interests of group in array with but it stores in jsonb.

The Data i am trying to store looks like

["Boxing","Badminton","Basketball","Bowling"]

My current DB

type Group struct {
    ID        uint `gorm:"primaryKey"`
    Name      string `gorm:"size:255;not null" json:"groupName"`
}

type GroupDetails struct{
    ID          uint `gorm:"primaryKey"`
    GroupId     uint
    GroupUserIds pgtype.JSONB 
    GroupInterests  pgtype.JSONB 
}

A group id can have multiple userIds and groupInterests. Thats why i am making an array of group userIds and groupInterests.

Even changing the type from pgtype.JSONB doesnt help. Is there something i am missing?

0

There are 0 answers