hola-server 0.7.1 → 0.7.2

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/db.js CHANGED
@@ -149,6 +149,15 @@ class DB {
149
149
  });
150
150
  }
151
151
 
152
+ /**
153
+ * get db collection
154
+ * @param {mongodb collection name} code
155
+ * @returns
156
+ */
157
+ get_col(code) {
158
+ return this.db[code];
159
+ }
160
+
152
161
  /**
153
162
  * Insert Object to db
154
163
  * @param {mongodb collection name} code
package/db/entity.js CHANGED
@@ -4,7 +4,7 @@ const { required_params } = require('../http/params');
4
4
  const { convert_type, convert_update_type, get_type } = require('../core/type');
5
5
  const { get_entity_meta, DELETE_MODE } = require('../core/meta');
6
6
  const { unique, map_array_to_obj } = require('../core/array');
7
- const { LOG_ENTITY, get_db, oid_query, oid_queries, is_log_debug, is_log_error, log_debug, log_error, get_session_userid } = require('./db');
7
+ const { LOG_ENTITY, get_db, oid_query, oid_queries, is_log_debug, is_log_error, log_debug, log_error, get_session_userid, bulk_update } = require('./db');
8
8
 
9
9
  /**
10
10
  * Convert search value type, if there is error, keep it
@@ -63,6 +63,25 @@ class Entity {
63
63
  this.db = get_db();
64
64
  }
65
65
 
66
+ /**
67
+ *
68
+ * @returns mongo underlying collection
69
+ */
70
+ get_col() {
71
+ return this.db.get_col(this.meta.collection);
72
+ }
73
+
74
+ /**
75
+ * Execute bulk update using the items
76
+ * @param {the items to execute bulk update} items
77
+ * @param {the attributes used as search criteria} attrs
78
+ * @returns
79
+ */
80
+ async bulk_update(items, attrs) {
81
+ const col = this.get_col();
82
+ await bulk_update(col, items, attrs);
83
+ }
84
+
66
85
  /**
67
86
  * validate the ref value, if success, return code:SUCCESS
68
87
  * and if the value is ref_label then convert ref_label to objectid
package/index.js CHANGED
@@ -27,10 +27,10 @@ const context = require('./http/context');
27
27
  const gridfs = require('./db/gridfs');
28
28
 
29
29
  const { gen_i18n } = require('./tool/gen_i18n');
30
- const { log_debug, log_info, log_warn, log_error, is_log_debug, is_log_info, is_log_warn, is_log_error, get_session_userid, oid_queries, oid_query, bulk_update } = require('./db/db');
30
+ const { log_debug, log_info, log_warn, log_error, is_log_debug, is_log_info, is_log_warn, is_log_error, get_session_userid, oid_queries, oid_query } = require('./db/db');
31
31
 
32
32
  module.exports = {
33
33
  init_settings, is_root_role, init_express_server, init_router, register_type, get_type, get_db, url,
34
34
  Entity, EntityMeta, get_entity_meta, array, bash, chart, cron, date, file, lhs, msg, number, obj, random, thread, validate, code, err, params, context, gridfs, gen_i18n,
35
- log_debug, log_info, log_warn, log_error, is_log_debug, is_log_info, is_log_warn, is_log_error, get_session_userid, oid_queries, oid_query, bulk_update
35
+ log_debug, log_info, log_warn, log_error, is_log_debug, is_log_info, is_log_warn, is_log_error, get_session_userid, oid_queries, oid_query
36
36
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hola-server",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "a meta programming framework used to build nodejs restful api",
5
5
  "main": "index.js",
6
6
  "scripts": {