Browse Source

Fix JSON parse error when fetching data from database

master
Menci 6 years ago
parent
commit
08b9954a94
  1. 2
      models/common.js

2
models/common.js

@ -31,7 +31,7 @@ class Model {
let model = this.getModel();
let obj = JSON.parse(JSON.stringify(this.record.get({ plain: true })));
for (let key in obj) {
if (model.tableAttributes[key].type instanceof Sequelize.JSON) {
if (model.tableAttributes[key].type instanceof Sequelize.JSON && typeof obj[key] === 'string') {
try {
this[key] = JSON.parse(obj[key]);
} catch (e) {

Loading…
Cancel
Save