hola-server 0.3.20 → 0.3.22
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/core/meta.js +4 -1
- package/db/entity.js +14 -11
- package/package.json +1 -1
package/core/meta.js
CHANGED
|
@@ -48,7 +48,7 @@ const validate_field = (meta, field) => {
|
|
|
48
48
|
field.required = true;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
if (field.ref) {
|
|
51
|
+
if (field.ref && !field.link) {
|
|
52
52
|
const ref_meta = meta_manager[field.ref];
|
|
53
53
|
if (!ref_meta) {
|
|
54
54
|
throw new Error("meta:" + meta.collection + ",field:" + field.name + " refers invalid meta:" + field.ref + "]");
|
|
@@ -124,6 +124,9 @@ const validate_fields = (meta, fields) => {
|
|
|
124
124
|
}
|
|
125
125
|
//set type to link field type
|
|
126
126
|
field.type = link_entity_field.type;
|
|
127
|
+
if (link_entity_field.ref) {
|
|
128
|
+
field.ref = link_entity_field.ref;
|
|
129
|
+
}
|
|
127
130
|
}
|
|
128
131
|
}
|
|
129
132
|
});
|
package/db/entity.js
CHANGED
|
@@ -184,15 +184,16 @@ class Entity {
|
|
|
184
184
|
const link_fields = [];
|
|
185
185
|
|
|
186
186
|
const attrs = {};
|
|
187
|
+
const fields_map = this.meta.fields_map;
|
|
187
188
|
attr_names.split(",").forEach((attr) => {
|
|
188
189
|
if (list_field_names.includes(attr)) {
|
|
189
190
|
attrs[attr] = 1;
|
|
190
|
-
const field =
|
|
191
|
-
if (field.
|
|
192
|
-
ref_fields.push(field);
|
|
193
|
-
} else if (field.link) {
|
|
191
|
+
const field = fields_map[attr];
|
|
192
|
+
if (field.link) {
|
|
194
193
|
link_fields.push(field);
|
|
195
194
|
attrs[field.link] = 1;
|
|
195
|
+
} else if (field.ref) {
|
|
196
|
+
ref_fields.push(field);
|
|
196
197
|
}
|
|
197
198
|
}
|
|
198
199
|
});
|
|
@@ -549,7 +550,7 @@ class Entity {
|
|
|
549
550
|
|
|
550
551
|
const field_names = this.meta.property_fields.map(f => f.name);
|
|
551
552
|
const attrs = {};
|
|
552
|
-
attr_names.split(",").forEach(
|
|
553
|
+
attr_names.split(",").forEach((attr) => {
|
|
553
554
|
if (field_names.includes(attr)) {
|
|
554
555
|
attrs[attr] = 1;
|
|
555
556
|
}
|
|
@@ -593,15 +594,17 @@ class Entity {
|
|
|
593
594
|
const ref_fields = [];
|
|
594
595
|
const link_fields = [];
|
|
595
596
|
const attrs = {};
|
|
596
|
-
|
|
597
|
+
|
|
598
|
+
const fields_map = this.meta.fields_map;
|
|
599
|
+
attr_names.split(",").forEach((attr) => {
|
|
597
600
|
if (field_names.includes(attr)) {
|
|
598
601
|
attrs[attr] = 1;
|
|
599
|
-
const field =
|
|
600
|
-
if (field.
|
|
601
|
-
ref_fields.push(field);
|
|
602
|
-
} else if (field.link) {
|
|
602
|
+
const field = fields_map[attr];
|
|
603
|
+
if (field.link) {
|
|
603
604
|
link_fields.push(field);
|
|
604
605
|
attrs[field.link] = 1;
|
|
606
|
+
} else if (field.ref) {
|
|
607
|
+
ref_fields.push(field);
|
|
605
608
|
}
|
|
606
609
|
}
|
|
607
610
|
});
|
|
@@ -987,7 +990,7 @@ class Entity {
|
|
|
987
990
|
attr_fields.forEach((attr) => {
|
|
988
991
|
attrs[attr] = 1;
|
|
989
992
|
const field = meta.fields_map[attr];
|
|
990
|
-
if (field.ref) {
|
|
993
|
+
if (!field.link && field.ref) {
|
|
991
994
|
ref_fields.push(field);
|
|
992
995
|
}
|
|
993
996
|
});
|