@snowtop/ent 0.1.0-alpha92-56721980-4046-11ed-ba1f-832778cd7daa → 0.1.0-alpha92-7ebc5680-4591-11ed-b331-8b0a5597e9d8
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/schema/struct_field.js +16 -16
package/package.json
CHANGED
package/schema/struct_field.js
CHANGED
|
@@ -23,27 +23,28 @@ class StructField extends field_1.BaseField {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
// right now, we store things in the db in lowerCase format
|
|
27
|
-
// this will lead to issues if field changes.
|
|
28
|
-
// TODO: use storageKey and convert back...
|
|
29
26
|
formatImpl(obj, nested) {
|
|
30
27
|
if (!(obj instanceof Object)) {
|
|
31
28
|
throw new Error("valid was not called");
|
|
32
29
|
}
|
|
33
30
|
let ret = {};
|
|
34
31
|
for (const k in this.options.fields) {
|
|
32
|
+
const field = this.options.fields[k];
|
|
33
|
+
// check two values
|
|
34
|
+
// wait, two different things
|
|
35
|
+
// getStoragetKey and getCamelCase()
|
|
36
|
+
// for weird graphql case and for typescript format...
|
|
37
|
+
// store in dbKey format
|
|
35
38
|
// TODO more #510
|
|
36
|
-
let dbKey = (0,
|
|
37
|
-
let
|
|
38
|
-
|
|
39
|
-
if (val === undefined && obj[
|
|
40
|
-
val = obj[
|
|
41
|
-
dbKey = k;
|
|
39
|
+
let dbKey = (0, schema_1.getStorageKey)(field, k);
|
|
40
|
+
let camelKey = (0, camel_case_1.camelCase)(k);
|
|
41
|
+
let val = obj[camelKey];
|
|
42
|
+
if (val === undefined && obj[dbKey] !== undefined) {
|
|
43
|
+
val = obj[dbKey];
|
|
42
44
|
}
|
|
43
45
|
if (val === undefined) {
|
|
44
46
|
continue;
|
|
45
47
|
}
|
|
46
|
-
const field = this.options.fields[k];
|
|
47
48
|
if (field.format) {
|
|
48
49
|
// indicate nested so this isn't JSON stringified
|
|
49
50
|
ret[dbKey] = field.format(val, true);
|
|
@@ -78,12 +79,11 @@ class StructField extends field_1.BaseField {
|
|
|
78
79
|
for (const k in this.options.fields) {
|
|
79
80
|
const field = this.options.fields[k];
|
|
80
81
|
// TODO more #510
|
|
81
|
-
let dbKey = (0,
|
|
82
|
-
let
|
|
83
|
-
|
|
84
|
-
if (val === undefined && obj[
|
|
85
|
-
val = obj[
|
|
86
|
-
dbKey = k;
|
|
82
|
+
let dbKey = (0, schema_1.getStorageKey)(field, k);
|
|
83
|
+
let camelKey = (0, camel_case_1.camelCase)(k);
|
|
84
|
+
let val = obj[camelKey];
|
|
85
|
+
if (val === undefined && obj[dbKey] !== undefined) {
|
|
86
|
+
val = obj[dbKey];
|
|
87
87
|
}
|
|
88
88
|
if (val === undefined || val === null) {
|
|
89
89
|
// nullable, nothing to do here
|