electrodb 2.10.4 → 2.10.6
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/library-data.json +9152 -0
- package/package.json +1 -1
- package/src/entity.js +10 -6
- package/src/operations.js +14 -0
package/package.json
CHANGED
package/src/entity.js
CHANGED
|
@@ -1014,13 +1014,17 @@ class Entity {
|
|
|
1014
1014
|
|
|
1015
1015
|
return { data: results };
|
|
1016
1016
|
} catch (err) {
|
|
1017
|
-
if (
|
|
1017
|
+
if (
|
|
1018
|
+
config.originalErr ||
|
|
1019
|
+
stackTrace === undefined ||
|
|
1020
|
+
err.isElectroError
|
|
1021
|
+
) {
|
|
1018
1022
|
throw err;
|
|
1019
1023
|
} else {
|
|
1020
1024
|
const error = new e.ElectroError(
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1025
|
+
e.ErrorCodes.AWSError,
|
|
1026
|
+
err.message,
|
|
1027
|
+
err,
|
|
1024
1028
|
);
|
|
1025
1029
|
error.stack = stackTrace;
|
|
1026
1030
|
|
|
@@ -2317,7 +2321,7 @@ class Entity {
|
|
|
2317
2321
|
// TODO: This will only work with root attributes and should be refactored for nested attributes.
|
|
2318
2322
|
update.set(attr.field, preparedUpdateValues[path]);
|
|
2319
2323
|
} else {
|
|
2320
|
-
// this could be fields added by electro that don't
|
|
2324
|
+
// this could be fields added by electro that don't appear in the schema
|
|
2321
2325
|
update.set(path, preparedUpdateValues[path]);
|
|
2322
2326
|
}
|
|
2323
2327
|
}
|
|
@@ -2369,7 +2373,7 @@ class Entity {
|
|
|
2369
2373
|
modifiedAttributeNames[primaryIndexAttribute] === undefined;
|
|
2370
2374
|
if (isNotTablePK && isNotTableSK && wasNotAlreadyModified) {
|
|
2371
2375
|
update.set(
|
|
2372
|
-
|
|
2376
|
+
attribute.field,
|
|
2373
2377
|
primaryIndexAttributes[primaryIndexAttribute],
|
|
2374
2378
|
);
|
|
2375
2379
|
}
|
package/src/operations.js
CHANGED
|
@@ -28,8 +28,21 @@ class ExpressionState {
|
|
|
28
28
|
return `${this.prefix}${this.counts[name]++}`;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
formatName(name = "") {
|
|
32
|
+
const nameWasNotANumber = isNaN(name);
|
|
33
|
+
name = `${name}`.replaceAll(/[^\w]/g, "");
|
|
34
|
+
if (name.length === 0) {
|
|
35
|
+
name = "p";
|
|
36
|
+
} else if (nameWasNotANumber !== isNaN(name)) {
|
|
37
|
+
// name became number due to replace
|
|
38
|
+
name = `p${name}`;
|
|
39
|
+
}
|
|
40
|
+
return name;
|
|
41
|
+
}
|
|
42
|
+
|
|
31
43
|
// todo: make the structure: name, value, paths
|
|
32
44
|
setName(paths, name, value) {
|
|
45
|
+
name = this.formatName(name);
|
|
33
46
|
let json = "";
|
|
34
47
|
let expression = "";
|
|
35
48
|
const prop = `#${name}`;
|
|
@@ -53,6 +66,7 @@ class ExpressionState {
|
|
|
53
66
|
}
|
|
54
67
|
|
|
55
68
|
setValue(name, value) {
|
|
69
|
+
name = this.formatName(name);
|
|
56
70
|
let valueCount = this.incrementName(name);
|
|
57
71
|
let expression = `:${name}${valueCount}`;
|
|
58
72
|
this.values[expression] = value;
|