@yuneta/gobj-js 7.26.9 → 7.26.10
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/dist/gobj-js.cjs.js +21 -12
- package/dist/gobj-js.cjs.js.map +1 -1
- package/dist/gobj-js.cjs.min.js +6 -9
- package/dist/gobj-js.cjs.min.js.map +1 -1
- package/dist/gobj-js.es.js +21 -12
- package/dist/gobj-js.es.js.map +1 -1
- package/dist/gobj-js.es.min.js +6 -9
- package/dist/gobj-js.es.min.js.map +1 -1
- package/dist/gobj-js.iife.js +21 -12
- package/dist/gobj-js.iife.js.map +1 -1
- package/dist/gobj-js.iife.min.js +6 -9
- package/dist/gobj-js.iife.min.js.map +1 -1
- package/dist/gobj-js.umd.js +21 -12
- package/dist/gobj-js.umd.js.map +1 -1
- package/dist/gobj-js.umd.min.js +148 -151
- package/dist/gobj-js.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/gobj-js.cjs.js
CHANGED
|
@@ -4439,6 +4439,10 @@ function kw_set_dict_value(gobj, kw, path, value) {
|
|
|
4439
4439
|
log_error(`${gobj ? gobj_short_name(gobj) + ": " : ""}kw_set_dict_value(): path must be a string: ${String(path)}`);
|
|
4440
4440
|
return -1;
|
|
4441
4441
|
}
|
|
4442
|
+
if (path === "") {
|
|
4443
|
+
log_error(`${gobj ? gobj_short_name(gobj) + ": " : ""}kw_set_dict_value(): path empty`);
|
|
4444
|
+
return -1;
|
|
4445
|
+
}
|
|
4442
4446
|
let ss = path.split("`");
|
|
4443
4447
|
let len = ss.length;
|
|
4444
4448
|
for (let i = 0; i < len; i++) {
|
|
@@ -5228,7 +5232,7 @@ function jdb_init(jdb, prefix, duplicate) {
|
|
|
5228
5232
|
let schema = kw_get_dict_value(null, jdb, "schema", {}, kw_flag_t.KW_CREATE);
|
|
5229
5233
|
let topics = kw_get_dict_value(null, jdb, "topics", {}, kw_flag_t.KW_CREATE);
|
|
5230
5234
|
let walk = function(obj, key, value, full_path) {
|
|
5231
|
-
if (key.substring(0, 2) !== "__") kw_get_dict_value(null, topics, full_path, json_deep_copy(type), kw_flag_t.KW_CREATE);
|
|
5235
|
+
if (key.substring(0, 2) !== "__" && !is_object(value)) kw_get_dict_value(null, topics, full_path, json_deep_copy(type), kw_flag_t.KW_CREATE);
|
|
5232
5236
|
};
|
|
5233
5237
|
_traverse_dict(schema, walk, prefix);
|
|
5234
5238
|
return jdb;
|
|
@@ -5259,6 +5263,10 @@ function jdb_update(jdb, topic_name, path, kw) {
|
|
|
5259
5263
|
if (is_object(v)) v = kw_get_dict_value(null, v, jdb.hook, [], kw_flag_t.KW_CREATE);
|
|
5260
5264
|
v = _jdb_get(v, null, id, false);
|
|
5261
5265
|
}
|
|
5266
|
+
if (!v || ids.length !== 0) {
|
|
5267
|
+
log_error(`jdb_update: path not found in topic '${topic_name}': '${path}'`);
|
|
5268
|
+
return null;
|
|
5269
|
+
}
|
|
5262
5270
|
if (ids.length === 0 && v) {
|
|
5263
5271
|
if (is_array(v)) v.push(kw);
|
|
5264
5272
|
else if (v["id"] === kw["id"]) json_object_update(v, kw);
|
|
@@ -5297,29 +5305,30 @@ function jdb_delete(jdb, topic_name, path, kw) {
|
|
|
5297
5305
|
if (is_object(v)) v = kw_get_dict_value(null, v, jdb.hook, null, 0);
|
|
5298
5306
|
v = _jdb_get(v, null, id, false);
|
|
5299
5307
|
}
|
|
5300
|
-
if (ids.length
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5308
|
+
if (!v || ids.length !== 0) {
|
|
5309
|
+
log_error(`jdb_delete: path not found in topic '${topic_name}': '${path}'`);
|
|
5310
|
+
return null;
|
|
5311
|
+
}
|
|
5312
|
+
let list = is_array(v) ? v : kw_get_dict_value(null, v, jdb.hook, null, 0);
|
|
5313
|
+
let idx = id_index_in_obj_list(list, kw["id"]);
|
|
5314
|
+
if (idx < 0) {
|
|
5315
|
+
log_error(`jdb_delete: record not found in topic '${topic_name}': '${path}' '${kw["id"]}'`);
|
|
5316
|
+
return null;
|
|
5309
5317
|
}
|
|
5318
|
+
list.splice(idx, 1);
|
|
5310
5319
|
return topic;
|
|
5311
5320
|
}
|
|
5312
5321
|
/********************************************
|
|
5313
5322
|
*
|
|
5314
5323
|
********************************************/
|
|
5315
5324
|
function jdb_get_topic(jdb, topic_name) {
|
|
5316
|
-
let topics = kw_get_dict_value(null, jdb, "topics", null, 0
|
|
5325
|
+
let topics = kw_get_dict_value(null, jdb, "topics", null, 0);
|
|
5317
5326
|
if (!topics) {
|
|
5318
5327
|
log_error("jdb topics section not found");
|
|
5319
5328
|
trace_msg(jdb);
|
|
5320
5329
|
return null;
|
|
5321
5330
|
}
|
|
5322
|
-
let topic = kw_get_dict_value(null, topics, topic_name, null, 0
|
|
5331
|
+
let topic = kw_get_dict_value(null, topics, topic_name, null, 0);
|
|
5323
5332
|
if (!topic) {
|
|
5324
5333
|
log_error("jdb topic not found: " + topic_name);
|
|
5325
5334
|
trace_msg(topics);
|