@itleanchatbot/shared-models-js-postgres 1.1.30 → 1.1.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/dialogNodes.js +21 -5
package/package.json
CHANGED
package/src/dialogNodes.js
CHANGED
|
@@ -77,7 +77,7 @@ const DialogNodesModel = (sequelize, Sequelize) => {
|
|
|
77
77
|
contexts: {
|
|
78
78
|
type: Sequelize.TEXT,
|
|
79
79
|
allowNull: false,
|
|
80
|
-
defaultValue:
|
|
80
|
+
defaultValue: '',
|
|
81
81
|
set(value, field) {
|
|
82
82
|
try {
|
|
83
83
|
const string = JSON.stringify(value.map(item => {
|
|
@@ -95,11 +95,27 @@ const DialogNodesModel = (sequelize, Sequelize) => {
|
|
|
95
95
|
}
|
|
96
96
|
},
|
|
97
97
|
get(field) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
try {
|
|
99
|
+
let value = this.getDataValue(field)
|
|
100
|
+
value = JSON.parse(value)
|
|
101
|
+
if (value.length) {
|
|
102
|
+
return value.map(item => {
|
|
103
|
+
try {
|
|
104
|
+
if(typeof item === 'string') {
|
|
105
|
+
return JSON.parse(item)
|
|
106
|
+
} else {
|
|
107
|
+
return item
|
|
108
|
+
}
|
|
109
|
+
} catch (error) {
|
|
110
|
+
console.error(error)
|
|
111
|
+
return item
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
return value
|
|
116
|
+
} catch (error) {
|
|
117
|
+
return this.getDataValue(field)
|
|
101
118
|
}
|
|
102
|
-
return value
|
|
103
119
|
},
|
|
104
120
|
},
|
|
105
121
|
})
|