hola-server 1.0.2 → 1.0.4

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.
Files changed (2) hide show
  1. package/db/entity.js +5 -4
  2. package/package.json +1 -1
package/db/entity.js CHANGED
@@ -258,7 +258,7 @@ class Entity {
258
258
  * @returns object with code and err
259
259
  */
260
260
  async create_entity(param_obj, view) {
261
- const fields = view == "*" ? this.meta.create_fields : this.meta.create_fields.filter(field => field.view == view);
261
+ const fields = view == "*" ? this.meta.create_fields : this.meta.create_fields.filter(field => field.view == view || field.view == "*");
262
262
  const { obj, error_field_names } = convert_type(param_obj, fields);
263
263
  if (error_field_names.length > 0) {
264
264
  if (is_log_error()) {
@@ -421,7 +421,7 @@ class Entity {
421
421
  *
422
422
  */
423
423
  async update_entity(_id, param_obj, view) {
424
- const fields = view == "*" ? this.meta.update_fields : this.meta.update_fields.filter(field => field.view == view);
424
+ const fields = view == "*" ? this.meta.update_fields : this.meta.update_fields.filter(field => field.view == view || field.view == "*");
425
425
 
426
426
  const { obj, error_field_names } = convert_update_type(param_obj, fields);
427
427
  if (error_field_names.length > 0) {
@@ -1067,6 +1067,7 @@ class Entity {
1067
1067
  }
1068
1068
 
1069
1069
  const search_fields = this.meta.search_fields;
1070
+ let search_query = {};
1070
1071
  //client query: key:value, key:value
1071
1072
  if (client_query && client_query.trim().length > 0 && search_fields && search_fields.length > 0) {
1072
1073
  const queries = client_query.split(",");
@@ -1075,7 +1076,7 @@ class Entity {
1075
1076
  if (query_values && query_values.length == 2) {
1076
1077
  const field_name = query_values[0];
1077
1078
  const [search_field] = search_fields.filter(f => f.name == field_name);
1078
- search_field && (query[field_name] = parse_search_value(field_name, search_field.type, query_values[1]))
1079
+ search_field && (search_query = parse_search_value(field_name, search_field.type, query_values[1]))
1079
1080
  }
1080
1081
  }
1081
1082
  }
@@ -1087,7 +1088,7 @@ class Entity {
1087
1088
  query = { ...query, ...this.meta.ref_filter["*"] };
1088
1089
  }
1089
1090
  }
1090
- 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 });
1091
1092
  }
1092
1093
 
1093
1094
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hola-server",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "a meta programming framework used to build nodejs restful api",
5
5
  "main": "index.js",
6
6
  "scripts": {