如何创建模型的数据库架构时所需的数据库字段是JSON?

问题描述 投票:0回答:1

目前,我已很少JSON领域模型中的“对象”,但我想这些字段是JSON在数据库中。然而,当我自动迁移它,领域越来越创建为MySQL中的文本?如何解决这一问题?

"education": {
    "type": "object"
},
"technology": {
    "type": "object"
},
"certificationsAndAchievements": {
    "type": "object"
}
loopbackjs
1个回答
0
投票

您可以使用您的模型的mysql选项,并设置dataTypeJSON。现在,在迁移时,这将是列式

{
  "education": {
    "type": "object",
    "mysql": {
      "dataType":"JSON"
    }
  },
  "technology": {
    "type": "object",
    "mysql": {
      "dataType":"JSON"
    }
  },
  "certificationsAndAchievements": {
    "type": "object",
    "mysql": {
      "dataType":"JSON"
    }
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.