@yuneta/gobj-js 7.26.10 → 7.26.12
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 +29 -15
- package/dist/gobj-js.cjs.js.map +1 -1
- package/dist/gobj-js.cjs.min.js +190 -187
- package/dist/gobj-js.cjs.min.js.map +1 -1
- package/dist/gobj-js.es.js +29 -15
- package/dist/gobj-js.es.js.map +1 -1
- package/dist/gobj-js.es.min.js +173 -170
- package/dist/gobj-js.es.min.js.map +1 -1
- package/dist/gobj-js.iife.js +29 -15
- package/dist/gobj-js.iife.js.map +1 -1
- package/dist/gobj-js.iife.min.js +234 -231
- package/dist/gobj-js.iife.min.js.map +1 -1
- package/dist/gobj-js.umd.js +29 -15
- package/dist/gobj-js.umd.js.map +1 -1
- package/dist/gobj-js.umd.min.js +98 -95
- package/dist/gobj-js.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/gobj-js.iife.js
CHANGED
|
@@ -5247,37 +5247,48 @@ var gobjJs = (function(exports) {
|
|
|
5247
5247
|
log_error("jdb_update: topic not found: " + topic_name);
|
|
5248
5248
|
return null;
|
|
5249
5249
|
}
|
|
5250
|
-
if (empty_string(kw["id"])) {
|
|
5251
|
-
log_error(
|
|
5252
|
-
trace_msg(kw);
|
|
5250
|
+
if (!is_object(kw) || empty_string(kw["id"])) {
|
|
5251
|
+
log_error(`jdb_update: record without id: ${JSON.stringify(kw)}`);
|
|
5253
5252
|
return null;
|
|
5254
5253
|
}
|
|
5255
5254
|
if (!is_string(path)) {
|
|
5256
5255
|
log_error(`jdb_update: path must be a string: ${String(path)}`);
|
|
5257
5256
|
return null;
|
|
5258
5257
|
}
|
|
5258
|
+
if (path !== "" && path.split("`").includes("")) {
|
|
5259
|
+
log_error(`jdb_update: empty segment in path: '${path}'`);
|
|
5260
|
+
return null;
|
|
5261
|
+
}
|
|
5259
5262
|
let ids = path.split("`");
|
|
5260
5263
|
let id;
|
|
5261
5264
|
let v = topic;
|
|
5262
5265
|
while (id = ids.shift()) {
|
|
5263
5266
|
if (empty_string(id) || !v) break;
|
|
5264
|
-
if (is_object(v)) v = kw_get_dict_value(null, v, jdb.hook,
|
|
5267
|
+
if (is_object(v)) v = kw_get_dict_value(null, v, jdb.hook, null, 0);
|
|
5265
5268
|
v = _jdb_get(v, null, id, false);
|
|
5266
5269
|
}
|
|
5267
5270
|
if (!v || ids.length !== 0) {
|
|
5268
5271
|
log_error(`jdb_update: path not found in topic '${topic_name}': '${path}'`);
|
|
5269
5272
|
return null;
|
|
5270
5273
|
}
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5274
|
+
let list;
|
|
5275
|
+
if (is_array(v)) list = v;
|
|
5276
|
+
else if (v["id"] === kw["id"]) {
|
|
5277
|
+
json_object_update(v, kw);
|
|
5278
|
+
return topic;
|
|
5279
|
+
} else {
|
|
5280
|
+
list = kw_get_dict_value(null, v, jdb.hook, null, 0);
|
|
5281
|
+
if (list === null || list === void 0) {
|
|
5282
|
+
list = [];
|
|
5283
|
+
json_object_set(v, jdb.hook, list);
|
|
5284
|
+
} else if (!is_array(list)) {
|
|
5285
|
+
log_error(`jdb_update: the hook '${jdb.hook}' of '${path}' is not a list in topic '${topic_name}'`);
|
|
5286
|
+
return null;
|
|
5279
5287
|
}
|
|
5280
5288
|
}
|
|
5289
|
+
let found = _jdb_get(list, jdb.hook, kw["id"], false);
|
|
5290
|
+
if (found) json_object_update(found, kw);
|
|
5291
|
+
else list.push(kw);
|
|
5281
5292
|
return topic;
|
|
5282
5293
|
}
|
|
5283
5294
|
/********************************************
|
|
@@ -5289,15 +5300,18 @@ var gobjJs = (function(exports) {
|
|
|
5289
5300
|
log_error("jdb_delete: topic not found: " + topic_name);
|
|
5290
5301
|
return null;
|
|
5291
5302
|
}
|
|
5292
|
-
if (empty_string(kw["id"])) {
|
|
5293
|
-
log_error(
|
|
5294
|
-
trace_msg(kw);
|
|
5303
|
+
if (!is_object(kw) || empty_string(kw["id"])) {
|
|
5304
|
+
log_error(`jdb_delete: record without id: ${JSON.stringify(kw)}`);
|
|
5295
5305
|
return null;
|
|
5296
5306
|
}
|
|
5297
5307
|
if (!is_string(path)) {
|
|
5298
5308
|
log_error(`jdb_delete: path must be a string: ${String(path)}`);
|
|
5299
5309
|
return null;
|
|
5300
5310
|
}
|
|
5311
|
+
if (path !== "" && path.split("`").includes("")) {
|
|
5312
|
+
log_error(`jdb_delete: empty segment in path: '${path}'`);
|
|
5313
|
+
return null;
|
|
5314
|
+
}
|
|
5301
5315
|
let ids = path.split("`");
|
|
5302
5316
|
let id;
|
|
5303
5317
|
let v = topic;
|