@strapi/database 5.0.0-rc.6 → 5.0.0-rc.8
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/dist/fields/json.d.ts +1 -1
- package/dist/fields/json.d.ts.map +1 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/fields/json.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/fields/json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,KAAK;IAC1C,IAAI,CAAC,KAAK,EAAE,OAAO;
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/fields/json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,KAAK;IAC1C,IAAI,CAAC,KAAK,EAAE,OAAO;IAYnB,MAAM,CAAC,KAAK,EAAE,OAAO;CAsBtB"}
|
package/dist/index.js
CHANGED
|
@@ -2775,12 +2775,22 @@ class StringField extends Field {
|
|
|
2775
2775
|
}
|
|
2776
2776
|
class JSONField extends Field {
|
|
2777
2777
|
toDB(value) {
|
|
2778
|
-
|
|
2778
|
+
if (value == null) {
|
|
2779
|
+
return null;
|
|
2780
|
+
}
|
|
2781
|
+
if (typeof value === "object") {
|
|
2782
|
+
return JSON.stringify(value);
|
|
2783
|
+
}
|
|
2784
|
+
return value;
|
|
2779
2785
|
}
|
|
2780
2786
|
fromDB(value) {
|
|
2781
2787
|
try {
|
|
2782
2788
|
if (typeof value === "string") {
|
|
2783
|
-
|
|
2789
|
+
const parsedValue = JSON.parse(value);
|
|
2790
|
+
if (typeof parsedValue === "string") {
|
|
2791
|
+
return JSON.parse(parsedValue);
|
|
2792
|
+
}
|
|
2793
|
+
return parsedValue;
|
|
2784
2794
|
}
|
|
2785
2795
|
} catch (error) {
|
|
2786
2796
|
return value;
|