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