Jsonb с Beego Orm и Postgres - PullRequest
       36

Jsonb с Beego Orm и Postgres

0 голосов
/ 22 ноября 2018

Я использую Beego с Postgres в качестве базы данных.У меня есть определение модели ниже:

type Dashboards struct {
    Id          string    `json:"id" orm:"pk" valid:"Required"`
    UserId      string    `json:user_id orm:rel(fk);null`
    Title       string    `json:title`
    Widgets     string    `json:widgets orm:"type(jsonb);null"`
    WidgetGrid  string    `json:widget_grid orm:"type(jsonb);null"`
}

func init() {
   base.RegisterModel(new(Dashboards))
}

При просмотре postgres я получаю следующую схему

   Column    | Type | Collation | Nullable | Default  
-------------+------+-----------+----------+----------
id          | text |           | not null | 
user_id     | text |           | not null | ''::text
title       | text |           | not null | ''::text
widgets     | text |           | not null | ''::text
widget_grid | text |           | not null | ''::text

т.е. оба поля, которые я намереваюсь сохранить как jsonb, сохраняются как текст,Пожалуйста, объясните мне, как сохранить поле как jsonb здесь.Спасибо.

...