hola-server 1.0.1 → 1.0.3
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/db/entity.js +7 -3
- package/package.json +1 -1
package/db/entity.js
CHANGED
|
@@ -1066,13 +1066,17 @@ class Entity {
|
|
|
1066
1066
|
query[this.meta.user_field] = get_session_userid();
|
|
1067
1067
|
}
|
|
1068
1068
|
|
|
1069
|
+
const search_fields = this.meta.search_fields;
|
|
1070
|
+
let search_query = {};
|
|
1069
1071
|
//client query: key:value, key:value
|
|
1070
|
-
if (client_query && client_query.trim().length > 0) {
|
|
1072
|
+
if (client_query && client_query.trim().length > 0 && search_fields && search_fields.length > 0) {
|
|
1071
1073
|
const queries = client_query.split(",");
|
|
1072
1074
|
for (let i = 0; i < queries.length; i++) {
|
|
1073
1075
|
const query_values = queries[i].split(":");
|
|
1074
1076
|
if (query_values && query_values.length == 2) {
|
|
1075
|
-
|
|
1077
|
+
const field_name = query_values[0];
|
|
1078
|
+
const [search_field] = search_fields.filter(f => f.name == field_name);
|
|
1079
|
+
search_field && (search_query = parse_search_value(field_name, search_field.type, query_values[1]))
|
|
1076
1080
|
}
|
|
1077
1081
|
}
|
|
1078
1082
|
}
|
|
@@ -1084,7 +1088,7 @@ class Entity {
|
|
|
1084
1088
|
query = { ...query, ...this.meta.ref_filter["*"] };
|
|
1085
1089
|
}
|
|
1086
1090
|
}
|
|
1087
|
-
return this.find_sort(query, { [this.meta.ref_label]: 1 }, { [this.meta.ref_label]: 1 });
|
|
1091
|
+
return this.find_sort({ ...search_query, ...query }, { [this.meta.ref_label]: 1 }, { [this.meta.ref_label]: 1 });
|
|
1088
1092
|
}
|
|
1089
1093
|
|
|
1090
1094
|
/**
|