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