electrodb 2.12.1 → 2.12.2
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/package.json +1 -1
- package/src/entity.js +42 -11
- package/test.csv +117 -0
package/package.json
CHANGED
package/src/entity.js
CHANGED
|
@@ -2211,30 +2211,61 @@ class Entity {
|
|
|
2211
2211
|
let { pk, sk } = this._makeIndexKeys({
|
|
2212
2212
|
index: indexBase,
|
|
2213
2213
|
});
|
|
2214
|
+
|
|
2214
2215
|
let keys = this._makeParameterKey(indexBase, pk, ...sk);
|
|
2216
|
+
// trim empty key values (this can occur when keys are defined by users)
|
|
2217
|
+
for (let key in keys) {
|
|
2218
|
+
if (keys[key] === undefined || keys[key] === '') {
|
|
2219
|
+
delete keys[key];
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
|
|
2215
2223
|
let keyExpressions = this._expressionAttributeBuilder(keys);
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
ExpressionAttributeNames: this._mergeExpressionsAttributes(
|
|
2224
|
+
|
|
2225
|
+
const expressionAttributeNames = this._mergeExpressionsAttributes(
|
|
2219
2226
|
filter.getNames(),
|
|
2220
2227
|
keyExpressions.ExpressionAttributeNames,
|
|
2221
|
-
|
|
2222
|
-
|
|
2228
|
+
);
|
|
2229
|
+
|
|
2230
|
+
const expressionAttributeValues = this._mergeExpressionsAttributes(
|
|
2223
2231
|
filter.getValues(),
|
|
2224
2232
|
keyExpressions.ExpressionAttributeValues,
|
|
2225
|
-
|
|
2226
|
-
|
|
2233
|
+
);
|
|
2234
|
+
|
|
2235
|
+
|
|
2236
|
+
let params = {
|
|
2237
|
+
TableName: this.getTableName(),
|
|
2227
2238
|
};
|
|
2228
2239
|
|
|
2240
|
+
if (Object.keys(expressionAttributeNames).length) {
|
|
2241
|
+
params['ExpressionAttributeNames'] = expressionAttributeNames;
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
if (Object.keys(expressionAttributeValues).length) {
|
|
2245
|
+
params['ExpressionAttributeValues'] = expressionAttributeValues;
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2248
|
+
let filterExpressions = [];
|
|
2249
|
+
|
|
2250
|
+
if (keys[pkField]) {
|
|
2251
|
+
filterExpressions.push(`begins_with(#${pkField}, :${pkField})`);
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2229
2254
|
if (hasSortKey) {
|
|
2230
2255
|
let skField = this.model.indexes[accessPattern].sk.field;
|
|
2231
|
-
|
|
2256
|
+
if (keys[skField]) {
|
|
2257
|
+
filterExpressions.push(`begins_with(#${skField}, :${skField})`);
|
|
2258
|
+
}
|
|
2232
2259
|
}
|
|
2260
|
+
|
|
2233
2261
|
if (filter.build()) {
|
|
2234
|
-
|
|
2235
|
-
params.FilterExpression
|
|
2236
|
-
} AND ${filter.build()}`;
|
|
2262
|
+
filterExpressions.push(filter.build());
|
|
2237
2263
|
}
|
|
2264
|
+
|
|
2265
|
+
if (filterExpressions.length) {
|
|
2266
|
+
params.FilterExpression = filterExpressions.join(' AND ');
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2238
2269
|
return params;
|
|
2239
2270
|
}
|
|
2240
2271
|
|
package/test.csv
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
|
|
2
|
+
> electrodb@2.12.1 local:exec
|
|
3
|
+
> LOCAL_DYNAMO_ENDPOINT='http://localhost:8000' ts-node ./test/debug.ts
|
|
4
|
+
|
|
5
|
+
kind, op, value, region, plan, datetime
|
|
6
|
+
item, value, $test_1#region_central-1#plan_base#datetime_1989-07-01, central-1, Base, 1989-07-01
|
|
7
|
+
item, value, $test_1#region_central-1#plan_base#datetime_2023-12-01, central-1, Base, 2023-12-01
|
|
8
|
+
item, value, $test_1#region_central-1#plan_base#datetime_2024-12-01, central-1, Base, 2024-12-01
|
|
9
|
+
item, value, $test_1#region_central-1#plan_pro#datetime_1989-07-01, central-1, Pro, 1989-07-01
|
|
10
|
+
item, value, $test_1#region_central-1#plan_pro#datetime_2023-12-01, central-1, Pro, 2023-12-01
|
|
11
|
+
item, value, $test_1#region_central-1#plan_pro#datetime_2024-12-01, central-1, Pro, 2024-12-01
|
|
12
|
+
item, value, $test_1#region_central-1#plan_proplus#datetime_1989-07-01, central-1, ProPlus, 1989-07-01
|
|
13
|
+
item, value, $test_1#region_central-1#plan_proplus#datetime_2023-12-01, central-1, ProPlus, 2023-12-01
|
|
14
|
+
item, value, $test_1#region_central-1#plan_proplus#datetime_2024-12-01, central-1, ProPlus, 2024-12-01
|
|
15
|
+
item, value, $test_1#region_central-1#plan_special#datetime_1989-07-01, central-1, Special, 1989-07-01
|
|
16
|
+
item, value, $test_1#region_central-1#plan_special#datetime_2023-12-01, central-1, Special, 2023-12-01
|
|
17
|
+
item, value, $test_1#region_central-1#plan_special#datetime_2024-12-01, central-1, Special, 2024-12-01
|
|
18
|
+
item, value, $test_1#region_east-1#plan_base#datetime_1989-07-01, east-1, Base, 1989-07-01
|
|
19
|
+
item, value, $test_1#region_east-1#plan_base#datetime_2023-12-01, east-1, Base, 2023-12-01
|
|
20
|
+
item, value, $test_1#region_east-1#plan_base#datetime_2024-12-01, east-1, Base, 2024-12-01
|
|
21
|
+
item, value, $test_1#region_east-1#plan_pro#datetime_1989-07-01, east-1, Pro, 1989-07-01
|
|
22
|
+
item, value, $test_1#region_east-1#plan_pro#datetime_2023-12-01, east-1, Pro, 2023-12-01
|
|
23
|
+
item, value, $test_1#region_east-1#plan_pro#datetime_2024-12-01, east-1, Pro, 2024-12-01
|
|
24
|
+
item, value, $test_1#region_east-1#plan_proplus#datetime_1989-07-01, east-1, ProPlus, 1989-07-01
|
|
25
|
+
item, value, $test_1#region_east-1#plan_proplus#datetime_2023-12-01, east-1, ProPlus, 2023-12-01
|
|
26
|
+
item, value, $test_1#region_east-1#plan_proplus#datetime_2024-12-01, east-1, ProPlus, 2024-12-01
|
|
27
|
+
item, value, $test_1#region_east-1#plan_special#datetime_1989-07-01, east-1, Special, 1989-07-01
|
|
28
|
+
item, value, $test_1#region_east-1#plan_special#datetime_2023-12-01, east-1, Special, 2023-12-01
|
|
29
|
+
item, value, $test_1#region_east-1#plan_special#datetime_2024-12-01, east-1, Special, 2024-12-01
|
|
30
|
+
item, value, $test_1#region_east-2#plan_base#datetime_1989-07-01, east-2, Base, 1989-07-01
|
|
31
|
+
item, value, $test_1#region_east-2#plan_base#datetime_2023-12-01, east-2, Base, 2023-12-01
|
|
32
|
+
item, value, $test_1#region_east-2#plan_base#datetime_2024-12-01, east-2, Base, 2024-12-01
|
|
33
|
+
item, value, $test_1#region_east-2#plan_pro#datetime_1989-07-01, east-2, Pro, 1989-07-01
|
|
34
|
+
item, value, $test_1#region_east-2#plan_pro#datetime_2023-12-01, east-2, Pro, 2023-12-01
|
|
35
|
+
item, value, $test_1#region_east-2#plan_pro#datetime_2024-12-01, east-2, Pro, 2024-12-01
|
|
36
|
+
item, value, $test_1#region_east-2#plan_proplus#datetime_1989-07-01, east-2, ProPlus, 1989-07-01
|
|
37
|
+
item, value, $test_1#region_east-2#plan_proplus#datetime_2023-12-01, east-2, ProPlus, 2023-12-01
|
|
38
|
+
item, value, $test_1#region_east-2#plan_proplus#datetime_2024-12-01, east-2, ProPlus, 2024-12-01
|
|
39
|
+
item, value, $test_1#region_east-2#plan_special#datetime_1989-07-01, east-2, Special, 1989-07-01
|
|
40
|
+
item, value, $test_1#region_east-2#plan_special#datetime_2023-12-01, east-2, Special, 2023-12-01
|
|
41
|
+
item, value, $test_1#region_east-2#plan_special#datetime_2024-12-01, east-2, Special, 2024-12-01
|
|
42
|
+
item, value, $test_1#region_west-1#plan_base#datetime_1989-07-01, west-1, Base, 1989-07-01
|
|
43
|
+
item, value, $test_1#region_west-1#plan_base#datetime_2023-12-01, west-1, Base, 2023-12-01
|
|
44
|
+
item, value, $test_1#region_west-1#plan_base#datetime_2024-12-01, west-1, Base, 2024-12-01
|
|
45
|
+
item, value, $test_1#region_west-1#plan_pro#datetime_1989-07-01, west-1, Pro, 1989-07-01
|
|
46
|
+
item, value, $test_1#region_west-1#plan_pro#datetime_2023-12-01, west-1, Pro, 2023-12-01
|
|
47
|
+
item, value, $test_1#region_west-1#plan_pro#datetime_2024-12-01, west-1, Pro, 2024-12-01
|
|
48
|
+
item, value, $test_1#region_west-1#plan_proplus#datetime_1989-07-01, west-1, ProPlus, 1989-07-01
|
|
49
|
+
item, value, $test_1#region_west-1#plan_proplus#datetime_2023-12-01, west-1, ProPlus, 2023-12-01
|
|
50
|
+
item, value, $test_1#region_west-1#plan_proplus#datetime_2024-12-01, west-1, ProPlus, 2024-12-01
|
|
51
|
+
item, value, $test_1#region_west-1#plan_special#datetime_1989-07-01, west-1, Special, 1989-07-01
|
|
52
|
+
item, value, $test_1#region_west-1#plan_special#datetime_2023-12-01, west-1, Special, 2023-12-01
|
|
53
|
+
item, value, $test_1#region_west-1#plan_special#datetime_2024-12-01, west-1, Special, 2024-12-01
|
|
54
|
+
partials, all, $test_1#region_, , ,
|
|
55
|
+
partials, begins, $test_1, , ,
|
|
56
|
+
partials, gt, $test_2, , ,
|
|
57
|
+
partials, gte, $test_1, , ,
|
|
58
|
+
partials, lt, $test_1, , ,
|
|
59
|
+
partials, lte, $test_2, , ,
|
|
60
|
+
partials, between_start, $test_1, , ,
|
|
61
|
+
partials, between_end, $test_2, , ,
|
|
62
|
+
partials, all, $test_1#region_east#plan_, east, ,
|
|
63
|
+
partials, begins, $test_1#region_east, east, ,
|
|
64
|
+
partials, gt, $test_1#region_easu, east, ,
|
|
65
|
+
partials, gte, $test_1#region_east, east, ,
|
|
66
|
+
partials, lt, $test_1#region_east, east, ,
|
|
67
|
+
partials, lte, $test_1#region_easu, east, ,
|
|
68
|
+
partials, between_start, $test_1#region_east, east, ,
|
|
69
|
+
partials, between_end, $test_1#region_easu, east, ,
|
|
70
|
+
partials, all, $test_1#region_east#plan_pro#datetime_, east, Pro,
|
|
71
|
+
partials, begins, $test_1#region_east#plan_pro, east, Pro,
|
|
72
|
+
partials, gt, $test_1#region_east#plan_prp, east, Pro,
|
|
73
|
+
partials, gte, $test_1#region_east#plan_pro, east, Pro,
|
|
74
|
+
partials, lt, $test_1#region_east#plan_pro, east, Pro,
|
|
75
|
+
partials, lte, $test_1#region_east#plan_prp, east, Pro,
|
|
76
|
+
partials, between_start, $test_1#region_east#plan_pro, east, Pro,
|
|
77
|
+
partials, between_end, $test_1#region_east#plan_prp, east, Pro,
|
|
78
|
+
partials, all, $test_1#region_east#plan_pro#datetime_2023-12-00, east, Pro, 2023-12-00
|
|
79
|
+
partials, begins, $test_1#region_east#plan_pro#datetime_2023-12-00, east, Pro, 2023-12-00
|
|
80
|
+
partials, gt, $test_1#region_east#plan_pro#datetime_2023-12-01, east, Pro, 2023-12-00
|
|
81
|
+
partials, gte, $test_1#region_east#plan_pro#datetime_2023-12-00, east, Pro, 2023-12-00
|
|
82
|
+
partials, lt, $test_1#region_east#plan_pro#datetime_2023-12-00, east, Pro, 2023-12-00
|
|
83
|
+
partials, lte, $test_1#region_east#plan_pro#datetime_2023-12-01, east, Pro, 2023-12-00
|
|
84
|
+
partials, between_start, $test_1#region_east#plan_pro#datetime_2023-12-00, east, Pro, 2023-12-00
|
|
85
|
+
partials, between_end, $test_1#region_east#plan_pro#datetime_2023-12-01, east, Pro, 2023-12-00
|
|
86
|
+
complete, all, $test_1#region_, , ,
|
|
87
|
+
complete, begins, $test_1, , ,
|
|
88
|
+
complete, gt, $test_2, , ,
|
|
89
|
+
complete, gte, $test_1, , ,
|
|
90
|
+
complete, lt, $test_1, , ,
|
|
91
|
+
complete, lte, $test_2, , ,
|
|
92
|
+
complete, between_start, $test_1, , ,
|
|
93
|
+
complete, between_end, $test_2, , ,
|
|
94
|
+
complete, all, $test_1#region_east-1#plan_, east-1, ,
|
|
95
|
+
complete, begins, $test_1#region_east-1, east-1, ,
|
|
96
|
+
complete, gt, $test_1#region_east-2, east-1, ,
|
|
97
|
+
complete, gte, $test_1#region_east-1, east-1, ,
|
|
98
|
+
complete, lt, $test_1#region_east-1, east-1, ,
|
|
99
|
+
complete, lte, $test_1#region_east-2, east-1, ,
|
|
100
|
+
complete, between_start, $test_1#region_east-1, east-1, ,
|
|
101
|
+
complete, between_end, $test_1#region_east-2, east-1, ,
|
|
102
|
+
complete, all, $test_1#region_east-1#plan_proplus#datetime_, east-1, ProPlus,
|
|
103
|
+
complete, begins, $test_1#region_east-1#plan_proplus, east-1, ProPlus,
|
|
104
|
+
complete, gt, $test_1#region_east-1#plan_proplut, east-1, ProPlus,
|
|
105
|
+
complete, gte, $test_1#region_east-1#plan_proplus, east-1, ProPlus,
|
|
106
|
+
complete, lt, $test_1#region_east-1#plan_proplus, east-1, ProPlus,
|
|
107
|
+
complete, lte, $test_1#region_east-1#plan_proplut, east-1, ProPlus,
|
|
108
|
+
complete, between_start, $test_1#region_east-1#plan_proplus, east-1, ProPlus,
|
|
109
|
+
complete, between_end, $test_1#region_east-1#plan_proplut, east-1, ProPlus,
|
|
110
|
+
complete, all, $test_1#region_east-1#plan_proplus#datetime_2023-12-01, east-1, ProPlus, 2023-12-01
|
|
111
|
+
complete, begins, $test_1#region_east-1#plan_proplus#datetime_2023-12-01, east-1, ProPlus, 2023-12-01
|
|
112
|
+
complete, gt, $test_1#region_east-1#plan_proplus#datetime_2023-12-02, east-1, ProPlus, 2023-12-01
|
|
113
|
+
complete, gte, $test_1#region_east-1#plan_proplus#datetime_2023-12-01, east-1, ProPlus, 2023-12-01
|
|
114
|
+
complete, lt, $test_1#region_east-1#plan_proplus#datetime_2023-12-01, east-1, ProPlus, 2023-12-01
|
|
115
|
+
complete, lte, $test_1#region_east-1#plan_proplus#datetime_2023-12-02, east-1, ProPlus, 2023-12-01
|
|
116
|
+
complete, between_start, $test_1#region_east-1#plan_proplus#datetime_2023-12-01, east-1, ProPlus, 2023-12-01
|
|
117
|
+
complete, between_end, $test_1#region_east-1#plan_proplus#datetime_2023-12-02, east-1, ProPlus, 2023-12-01
|