dyno-table 0.1.8 → 0.2.0-0
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/README.md +570 -147
- package/dist/builder-types-C_PDZhnP.d.ts +118 -0
- package/dist/builder-types-DtwbqMeF.d.cts +118 -0
- package/dist/builders/condition-check-builder.cjs +1 -1
- package/dist/builders/condition-check-builder.cjs.map +1 -1
- package/dist/builders/condition-check-builder.d.cts +157 -0
- package/dist/builders/condition-check-builder.d.ts +157 -0
- package/dist/builders/condition-check-builder.js +1 -1
- package/dist/builders/condition-check-builder.js.map +1 -1
- package/dist/builders/delete-builder.cjs +0 -17
- package/dist/builders/delete-builder.cjs.map +1 -1
- package/dist/builders/delete-builder.d.cts +166 -0
- package/dist/builders/delete-builder.d.ts +166 -0
- package/dist/builders/delete-builder.js +0 -17
- package/dist/builders/delete-builder.js.map +1 -1
- package/dist/builders/paginator.cjs.map +1 -1
- package/dist/builders/paginator.d.cts +179 -0
- package/dist/builders/paginator.d.ts +179 -0
- package/dist/builders/paginator.js.map +1 -1
- package/dist/builders/put-builder.cjs +8 -0
- package/dist/builders/put-builder.cjs.map +1 -1
- package/dist/builders/put-builder.d.cts +274 -0
- package/dist/builders/put-builder.d.ts +274 -0
- package/dist/builders/put-builder.js +8 -0
- package/dist/builders/put-builder.js.map +1 -1
- package/dist/builders/query-builder.cjs.map +1 -1
- package/dist/builders/query-builder.d.cts +6 -0
- package/dist/builders/query-builder.d.ts +6 -0
- package/dist/builders/query-builder.js.map +1 -1
- package/dist/builders/transaction-builder.cjs +40 -22
- package/dist/builders/transaction-builder.cjs.map +1 -1
- package/dist/builders/transaction-builder.d.cts +511 -0
- package/dist/builders/transaction-builder.d.ts +511 -0
- package/dist/builders/transaction-builder.js +40 -22
- package/dist/builders/transaction-builder.js.map +1 -1
- package/dist/builders/update-builder.cjs +3 -38
- package/dist/builders/update-builder.cjs.map +1 -1
- package/dist/builders/update-builder.d.cts +365 -0
- package/dist/builders/update-builder.d.ts +365 -0
- package/dist/builders/update-builder.js +3 -38
- package/dist/builders/update-builder.js.map +1 -1
- package/dist/conditions--ld9a78i.d.ts +331 -0
- package/dist/conditions-ChhQWd6z.d.cts +331 -0
- package/dist/conditions.cjs.map +1 -1
- package/dist/conditions.d.cts +3 -0
- package/dist/conditions.d.ts +3 -0
- package/dist/conditions.js.map +1 -1
- package/dist/entity.cjs +156 -97
- package/dist/entity.cjs.map +1 -1
- package/dist/entity.d.cts +149 -0
- package/dist/entity.d.ts +149 -0
- package/dist/entity.js +156 -97
- package/dist/entity.js.map +1 -1
- package/dist/query-builder-Csror9Iu.d.ts +507 -0
- package/dist/query-builder-D2FM9rsu.d.cts +507 -0
- package/dist/standard-schema.d.cts +57 -0
- package/dist/standard-schema.d.ts +57 -0
- package/dist/table-BEhBPy2G.d.cts +364 -0
- package/dist/table-BW3cmUqr.d.ts +364 -0
- package/dist/table.cjs +82 -102
- package/dist/table.cjs.map +1 -1
- package/dist/table.d.cts +12 -0
- package/dist/table.d.ts +12 -0
- package/dist/table.js +82 -102
- package/dist/table.js.map +1 -1
- package/dist/types.d.cts +22 -0
- package/dist/types.d.ts +22 -0
- package/dist/utils/{key-template.cjs → partition-key-template.cjs} +3 -3
- package/dist/utils/partition-key-template.cjs.map +1 -0
- package/dist/utils/partition-key-template.d.cts +32 -0
- package/dist/utils/partition-key-template.d.ts +32 -0
- package/dist/utils/{key-template.js → partition-key-template.js} +3 -3
- package/dist/utils/partition-key-template.js.map +1 -0
- package/dist/utils/sort-key-template.d.cts +35 -0
- package/dist/utils/sort-key-template.d.ts +35 -0
- package/package.json +86 -9
- package/dist/index.cjs +0 -3333
- package/dist/index.d.cts +0 -2971
- package/dist/index.d.ts +0 -2971
- package/dist/index.js +0 -3284
- package/dist/utils/key-template.cjs.map +0 -1
- package/dist/utils/key-template.js.map +0 -1
package/dist/table.cjs
CHANGED
|
@@ -863,6 +863,14 @@ var PutBuilder = class {
|
|
|
863
863
|
returnValues: "NONE"
|
|
864
864
|
};
|
|
865
865
|
}
|
|
866
|
+
set(valuesOrPath, value) {
|
|
867
|
+
if (typeof valuesOrPath === "object") {
|
|
868
|
+
Object.assign(this.item, valuesOrPath);
|
|
869
|
+
} else {
|
|
870
|
+
this.item[valuesOrPath] = value;
|
|
871
|
+
}
|
|
872
|
+
return this;
|
|
873
|
+
}
|
|
866
874
|
/**
|
|
867
875
|
* Adds a condition that must be satisfied for the put operation to succeed.
|
|
868
876
|
* Use this method when you need to:
|
|
@@ -1107,10 +1115,6 @@ var DeleteBuilder = class {
|
|
|
1107
1115
|
}
|
|
1108
1116
|
/**
|
|
1109
1117
|
* Adds a condition that must be satisfied for the delete operation to succeed.
|
|
1110
|
-
* Use this method when you need to:
|
|
1111
|
-
* - Ensure safe removal conditions
|
|
1112
|
-
* - Verify habitat status before deletion
|
|
1113
|
-
* - Implement safety protocols
|
|
1114
1118
|
*
|
|
1115
1119
|
* @example
|
|
1116
1120
|
* ```typescript
|
|
@@ -1162,10 +1166,6 @@ var DeleteBuilder = class {
|
|
|
1162
1166
|
}
|
|
1163
1167
|
/**
|
|
1164
1168
|
* Sets whether to return the item's attribute values before deletion.
|
|
1165
|
-
* Use this method when you need to:
|
|
1166
|
-
* - Archive removed dinosaur data
|
|
1167
|
-
* - Track habitat decommissioning history
|
|
1168
|
-
* - Maintain removal audit logs
|
|
1169
1169
|
*
|
|
1170
1170
|
* @example
|
|
1171
1171
|
* ```ts
|
|
@@ -1206,10 +1206,6 @@ var DeleteBuilder = class {
|
|
|
1206
1206
|
}
|
|
1207
1207
|
/**
|
|
1208
1208
|
* Adds this delete operation to a transaction.
|
|
1209
|
-
* Use this method when you need to:
|
|
1210
|
-
* - Coordinate dinosaur transfers
|
|
1211
|
-
* - Manage habitat decommissioning
|
|
1212
|
-
* - Handle species relocations
|
|
1213
1209
|
*
|
|
1214
1210
|
* @example
|
|
1215
1211
|
* ```ts
|
|
@@ -1260,11 +1256,6 @@ var DeleteBuilder = class {
|
|
|
1260
1256
|
/**
|
|
1261
1257
|
* Gets a human-readable representation of the delete command
|
|
1262
1258
|
* with all expression placeholders replaced by their actual values.
|
|
1263
|
-
* Use this method when you need to:
|
|
1264
|
-
* - Debug complex deletion conditions
|
|
1265
|
-
* - Verify safety checks
|
|
1266
|
-
* - Log removal operations
|
|
1267
|
-
* - Troubleshoot failed deletions
|
|
1268
1259
|
*
|
|
1269
1260
|
* @example
|
|
1270
1261
|
* ```ts
|
|
@@ -1323,10 +1314,6 @@ var UpdateBuilder = class {
|
|
|
1323
1314
|
}
|
|
1324
1315
|
/**
|
|
1325
1316
|
* Removes an attribute from the item.
|
|
1326
|
-
* Use this method when you need to:
|
|
1327
|
-
* - Delete attributes completely
|
|
1328
|
-
* - Remove nested attributes
|
|
1329
|
-
* - Clean up deprecated fields
|
|
1330
1317
|
*
|
|
1331
1318
|
* @example
|
|
1332
1319
|
* ```typescript
|
|
@@ -1353,10 +1340,6 @@ var UpdateBuilder = class {
|
|
|
1353
1340
|
}
|
|
1354
1341
|
/**
|
|
1355
1342
|
* Adds a value to a number attribute or adds elements to a set.
|
|
1356
|
-
* Use this method when you need to:
|
|
1357
|
-
* - Increment counters
|
|
1358
|
-
* - Add elements to a set atomically
|
|
1359
|
-
* - Update numerical statistics
|
|
1360
1343
|
*
|
|
1361
1344
|
* @example
|
|
1362
1345
|
* ```typescript
|
|
@@ -1385,10 +1368,6 @@ var UpdateBuilder = class {
|
|
|
1385
1368
|
}
|
|
1386
1369
|
/**
|
|
1387
1370
|
* Removes elements from a set attribute.
|
|
1388
|
-
* Use this method when you need to:
|
|
1389
|
-
* - Remove specific elements from a set
|
|
1390
|
-
* - Update set-based attributes atomically
|
|
1391
|
-
* - Maintain set membership
|
|
1392
1371
|
*
|
|
1393
1372
|
* @example
|
|
1394
1373
|
* ```typescript
|
|
@@ -1398,7 +1377,7 @@ var UpdateBuilder = class {
|
|
|
1398
1377
|
* ['JUNGLE', 'COASTAL']
|
|
1399
1378
|
* );
|
|
1400
1379
|
*
|
|
1401
|
-
* // Remove from sets using Set
|
|
1380
|
+
* // Remove from sets using Set DynamoItems
|
|
1402
1381
|
* builder.deleteElementsFromSet(
|
|
1403
1382
|
* 'knownBehaviors',
|
|
1404
1383
|
* new Set(['NOCTURNAL', 'TERRITORIAL'])
|
|
@@ -1431,11 +1410,6 @@ var UpdateBuilder = class {
|
|
|
1431
1410
|
}
|
|
1432
1411
|
/**
|
|
1433
1412
|
* Adds a condition that must be satisfied for the update to succeed.
|
|
1434
|
-
* Use this method when you need to:
|
|
1435
|
-
* - Implement optimistic locking
|
|
1436
|
-
* - Ensure item state before update
|
|
1437
|
-
* - Validate business rules
|
|
1438
|
-
* - Prevent concurrent modifications
|
|
1439
1413
|
*
|
|
1440
1414
|
* @example
|
|
1441
1415
|
* ```typescript
|
|
@@ -1467,7 +1441,7 @@ var UpdateBuilder = class {
|
|
|
1467
1441
|
* );
|
|
1468
1442
|
* ```
|
|
1469
1443
|
*
|
|
1470
|
-
* @param condition - Either a Condition
|
|
1444
|
+
* @param condition - Either a Condition DynamoItem or a callback function that builds the condition
|
|
1471
1445
|
* @returns The builder instance for method chaining
|
|
1472
1446
|
*/
|
|
1473
1447
|
condition(condition) {
|
|
@@ -1496,11 +1470,6 @@ var UpdateBuilder = class {
|
|
|
1496
1470
|
}
|
|
1497
1471
|
/**
|
|
1498
1472
|
* Sets which item attributes to include in the response.
|
|
1499
|
-
* Use this method when you need to:
|
|
1500
|
-
* - Get the complete updated item
|
|
1501
|
-
* - Track changes to specific attributes
|
|
1502
|
-
* - Compare old and new values
|
|
1503
|
-
* - Monitor attribute modifications
|
|
1504
1473
|
*
|
|
1505
1474
|
* Available options:
|
|
1506
1475
|
* - ALL_NEW: All attributes after the update
|
|
@@ -1628,10 +1597,6 @@ var UpdateBuilder = class {
|
|
|
1628
1597
|
}
|
|
1629
1598
|
/**
|
|
1630
1599
|
* Adds this update operation to a transaction.
|
|
1631
|
-
* Use this method when you need to:
|
|
1632
|
-
* - Update items as part of a larger transaction
|
|
1633
|
-
* - Ensure multiple updates are atomic
|
|
1634
|
-
* - Coordinate updates across multiple items
|
|
1635
1600
|
*
|
|
1636
1601
|
* @example
|
|
1637
1602
|
* ```typescript
|
|
@@ -1661,11 +1626,6 @@ var UpdateBuilder = class {
|
|
|
1661
1626
|
}
|
|
1662
1627
|
/**
|
|
1663
1628
|
* Gets a human-readable representation of the update command.
|
|
1664
|
-
* Use this method when you need to:
|
|
1665
|
-
* - Debug complex update expressions
|
|
1666
|
-
* - Verify attribute names and values
|
|
1667
|
-
* - Log update operations
|
|
1668
|
-
* - Troubleshoot condition expressions
|
|
1669
1629
|
*
|
|
1670
1630
|
* @example
|
|
1671
1631
|
* ```typescript
|
|
@@ -1692,10 +1652,6 @@ var UpdateBuilder = class {
|
|
|
1692
1652
|
}
|
|
1693
1653
|
/**
|
|
1694
1654
|
* Executes the update operation against DynamoDB.
|
|
1695
|
-
* Use this method when you need to:
|
|
1696
|
-
* - Apply updates immediately
|
|
1697
|
-
* - Get the updated item values
|
|
1698
|
-
* - Handle conditional update failures
|
|
1699
1655
|
*
|
|
1700
1656
|
* @example
|
|
1701
1657
|
* ```typescript
|
|
@@ -1730,7 +1686,7 @@ var UpdateBuilder = class {
|
|
|
1730
1686
|
* }
|
|
1731
1687
|
* ```
|
|
1732
1688
|
*
|
|
1733
|
-
* @returns A promise that resolves to an
|
|
1689
|
+
* @returns A promise that resolves to an DynamoItem containing the updated item (if returnValues is set)
|
|
1734
1690
|
* @throws {ConditionalCheckFailedException} If the condition check fails
|
|
1735
1691
|
* @throws {Error} If the update operation fails for other reasons
|
|
1736
1692
|
*/
|
|
@@ -1784,7 +1740,7 @@ var TransactionBuilder = class {
|
|
|
1784
1740
|
*/
|
|
1785
1741
|
checkForDuplicateItem(tableName, newItem) {
|
|
1786
1742
|
const pkName = this.indexConfig.partitionKey;
|
|
1787
|
-
const skName = this.indexConfig.sortKey
|
|
1743
|
+
const skName = this.indexConfig.sortKey ?? "";
|
|
1788
1744
|
const pkValue = newItem[pkName];
|
|
1789
1745
|
const skValue = skName ? newItem[skName] : void 0;
|
|
1790
1746
|
if (!pkValue) {
|
|
@@ -1825,6 +1781,18 @@ var TransactionBuilder = class {
|
|
|
1825
1781
|
);
|
|
1826
1782
|
}
|
|
1827
1783
|
}
|
|
1784
|
+
createKeyForPrimaryIndex(key) {
|
|
1785
|
+
const keyCondition = {
|
|
1786
|
+
[this.indexConfig.partitionKey]: key.pk
|
|
1787
|
+
};
|
|
1788
|
+
if (this.indexConfig.sortKey) {
|
|
1789
|
+
if (key.sk === void 0) {
|
|
1790
|
+
throw new Error("Sort key is required for delete operation");
|
|
1791
|
+
}
|
|
1792
|
+
keyCondition[this.indexConfig.sortKey] = key.sk;
|
|
1793
|
+
}
|
|
1794
|
+
return keyCondition;
|
|
1795
|
+
}
|
|
1828
1796
|
/**
|
|
1829
1797
|
* Adds a put operation to the transaction.
|
|
1830
1798
|
* Use this method when you need to:
|
|
@@ -1964,15 +1932,13 @@ var TransactionBuilder = class {
|
|
|
1964
1932
|
* @throws {Error} If a duplicate item is detected in the transaction
|
|
1965
1933
|
*/
|
|
1966
1934
|
delete(tableName, key, condition) {
|
|
1967
|
-
this.
|
|
1935
|
+
const keyCondition = this.createKeyForPrimaryIndex(key);
|
|
1936
|
+
this.checkForDuplicateItem(tableName, keyCondition);
|
|
1968
1937
|
const transactionItem = {
|
|
1969
1938
|
type: "Delete",
|
|
1970
1939
|
params: {
|
|
1971
1940
|
tableName,
|
|
1972
|
-
key:
|
|
1973
|
-
pk: key.pk,
|
|
1974
|
-
sk: key.sk
|
|
1975
|
-
}
|
|
1941
|
+
key: keyCondition
|
|
1976
1942
|
}
|
|
1977
1943
|
};
|
|
1978
1944
|
if (condition) {
|
|
@@ -2014,10 +1980,14 @@ var TransactionBuilder = class {
|
|
|
2014
1980
|
* @see DeleteBuilder for creating delete commands
|
|
2015
1981
|
*/
|
|
2016
1982
|
deleteWithCommand(command) {
|
|
2017
|
-
this.
|
|
1983
|
+
const keyCondition = this.createKeyForPrimaryIndex(command.key);
|
|
1984
|
+
this.checkForDuplicateItem(command.tableName, keyCondition);
|
|
2018
1985
|
const transactionItem = {
|
|
2019
1986
|
type: "Delete",
|
|
2020
|
-
params:
|
|
1987
|
+
params: {
|
|
1988
|
+
...command,
|
|
1989
|
+
key: keyCondition
|
|
1990
|
+
}
|
|
2021
1991
|
};
|
|
2022
1992
|
this.items.push(transactionItem);
|
|
2023
1993
|
return this;
|
|
@@ -2077,15 +2047,13 @@ var TransactionBuilder = class {
|
|
|
2077
2047
|
* @throws {Error} If a duplicate item is detected in the transaction
|
|
2078
2048
|
*/
|
|
2079
2049
|
update(tableName, key, updateExpression, expressionAttributeNames, expressionAttributeValues, condition) {
|
|
2080
|
-
this.
|
|
2050
|
+
const keyCondition = this.createKeyForPrimaryIndex(key);
|
|
2051
|
+
this.checkForDuplicateItem(tableName, keyCondition);
|
|
2081
2052
|
const transactionItem = {
|
|
2082
2053
|
type: "Update",
|
|
2083
2054
|
params: {
|
|
2084
2055
|
tableName,
|
|
2085
|
-
key:
|
|
2086
|
-
pk: key.pk,
|
|
2087
|
-
sk: key.sk
|
|
2088
|
-
},
|
|
2056
|
+
key: keyCondition,
|
|
2089
2057
|
updateExpression,
|
|
2090
2058
|
expressionAttributeNames,
|
|
2091
2059
|
expressionAttributeValues
|
|
@@ -2139,10 +2107,14 @@ var TransactionBuilder = class {
|
|
|
2139
2107
|
* @see UpdateBuilder for creating update commands
|
|
2140
2108
|
*/
|
|
2141
2109
|
updateWithCommand(command) {
|
|
2142
|
-
this.
|
|
2110
|
+
const keyCondition = this.createKeyForPrimaryIndex(command.key);
|
|
2111
|
+
this.checkForDuplicateItem(command.tableName, keyCondition);
|
|
2143
2112
|
const transactionItem = {
|
|
2144
2113
|
type: "Update",
|
|
2145
|
-
params:
|
|
2114
|
+
params: {
|
|
2115
|
+
...command,
|
|
2116
|
+
key: keyCondition
|
|
2117
|
+
}
|
|
2146
2118
|
};
|
|
2147
2119
|
this.items.push(transactionItem);
|
|
2148
2120
|
return this;
|
|
@@ -2199,7 +2171,8 @@ var TransactionBuilder = class {
|
|
|
2199
2171
|
* @throws {Error} If condition expression generation fails
|
|
2200
2172
|
*/
|
|
2201
2173
|
conditionCheck(tableName, key, condition) {
|
|
2202
|
-
this.
|
|
2174
|
+
const keyCondition = this.createKeyForPrimaryIndex(key);
|
|
2175
|
+
this.checkForDuplicateItem(tableName, keyCondition);
|
|
2203
2176
|
const { expression, names, values } = prepareExpressionParams(condition);
|
|
2204
2177
|
if (!expression) {
|
|
2205
2178
|
throw new Error("Failed to generate condition expression");
|
|
@@ -2208,10 +2181,7 @@ var TransactionBuilder = class {
|
|
|
2208
2181
|
type: "ConditionCheck",
|
|
2209
2182
|
params: {
|
|
2210
2183
|
tableName,
|
|
2211
|
-
key:
|
|
2212
|
-
pk: key.pk,
|
|
2213
|
-
sk: key.sk
|
|
2214
|
-
},
|
|
2184
|
+
key: keyCondition,
|
|
2215
2185
|
conditionExpression: expression,
|
|
2216
2186
|
expressionAttributeNames: names,
|
|
2217
2187
|
expressionAttributeValues: values
|
|
@@ -2251,10 +2221,14 @@ var TransactionBuilder = class {
|
|
|
2251
2221
|
* @see ConditionCheckBuilder for creating condition check commands
|
|
2252
2222
|
*/
|
|
2253
2223
|
conditionCheckWithCommand(command) {
|
|
2254
|
-
this.
|
|
2224
|
+
const keyCondition = this.createKeyForPrimaryIndex(command.key);
|
|
2225
|
+
this.checkForDuplicateItem(command.tableName, keyCondition);
|
|
2255
2226
|
const transactionItem = {
|
|
2256
2227
|
type: "ConditionCheck",
|
|
2257
|
-
params:
|
|
2228
|
+
params: {
|
|
2229
|
+
...command,
|
|
2230
|
+
key: keyCondition
|
|
2231
|
+
}
|
|
2258
2232
|
};
|
|
2259
2233
|
this.items.push(transactionItem);
|
|
2260
2234
|
return this;
|
|
@@ -2487,7 +2461,7 @@ var ConditionCheckBuilder = class {
|
|
|
2487
2461
|
* );
|
|
2488
2462
|
* ```
|
|
2489
2463
|
*
|
|
2490
|
-
* @param condition - Either a Condition
|
|
2464
|
+
* @param condition - Either a Condition DynamoItem or a callback function that builds the condition
|
|
2491
2465
|
* @returns The builder instance for method chaining
|
|
2492
2466
|
*/
|
|
2493
2467
|
condition(condition) {
|
|
@@ -2713,18 +2687,18 @@ var GetBuilder = class {
|
|
|
2713
2687
|
* - item: The retrieved dinosaur or undefined if not found
|
|
2714
2688
|
*/
|
|
2715
2689
|
async execute() {
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
this.params
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2690
|
+
const expressionParams = {
|
|
2691
|
+
expressionAttributeNames: {},
|
|
2692
|
+
expressionAttributeValues: {},
|
|
2693
|
+
valueCounter: { count: 0 }
|
|
2694
|
+
};
|
|
2695
|
+
const projectionExpression = Array.from(this.selectedFields).map((p) => generateAttributeName(expressionParams, p)).join(", ");
|
|
2696
|
+
const { expressionAttributeNames } = expressionParams;
|
|
2697
|
+
return this.executor({
|
|
2698
|
+
...this.params,
|
|
2699
|
+
projectionExpression: projectionExpression.length > 0 ? projectionExpression : void 0,
|
|
2700
|
+
expressionAttributeNames: Object.keys(expressionAttributeNames).length > 0 ? expressionAttributeNames : void 0
|
|
2701
|
+
});
|
|
2728
2702
|
}
|
|
2729
2703
|
};
|
|
2730
2704
|
|
|
@@ -2819,6 +2793,16 @@ var Table = class {
|
|
|
2819
2793
|
this.sortKey = config.indexes.sortKey;
|
|
2820
2794
|
this.gsis = config.indexes.gsis || {};
|
|
2821
2795
|
}
|
|
2796
|
+
createKeyForPrimaryIndex(keyCondition) {
|
|
2797
|
+
const primaryCondition = { [this.partitionKey]: keyCondition.pk };
|
|
2798
|
+
if (this.sortKey) {
|
|
2799
|
+
if (!keyCondition.sk) {
|
|
2800
|
+
throw new Error("Sort key has not been provided but the Table has a sort key");
|
|
2801
|
+
}
|
|
2802
|
+
primaryCondition[this.sortKey] = keyCondition.sk;
|
|
2803
|
+
}
|
|
2804
|
+
return primaryCondition;
|
|
2805
|
+
}
|
|
2822
2806
|
/**
|
|
2823
2807
|
* Creates a new item in the table, it will fail if the item already exists
|
|
2824
2808
|
*
|
|
@@ -2833,7 +2817,7 @@ var Table = class {
|
|
|
2833
2817
|
try {
|
|
2834
2818
|
const result = await this.dynamoClient.get({
|
|
2835
2819
|
TableName: params.tableName,
|
|
2836
|
-
Key:
|
|
2820
|
+
Key: this.createKeyForPrimaryIndex(keyCondition),
|
|
2837
2821
|
ProjectionExpression: params.projectionExpression,
|
|
2838
2822
|
ExpressionAttributeNames: params.expressionAttributeNames,
|
|
2839
2823
|
ConsistentRead: params.consistentRead
|
|
@@ -2868,13 +2852,12 @@ var Table = class {
|
|
|
2868
2852
|
ReturnValues: params.returnValues === "CONSISTENT" ? "NONE" : params.returnValues
|
|
2869
2853
|
});
|
|
2870
2854
|
if (params.returnValues === "CONSISTENT") {
|
|
2871
|
-
const key = {
|
|
2872
|
-
pk: params.item[this.partitionKey],
|
|
2873
|
-
...this.sortKey && { sk: params.item[this.sortKey] }
|
|
2874
|
-
};
|
|
2875
2855
|
const getResult = await this.dynamoClient.get({
|
|
2876
2856
|
TableName: params.tableName,
|
|
2877
|
-
Key:
|
|
2857
|
+
Key: this.createKeyForPrimaryIndex({
|
|
2858
|
+
pk: params.item[this.partitionKey],
|
|
2859
|
+
...this.sortKey && { sk: params.item[this.sortKey] }
|
|
2860
|
+
}),
|
|
2878
2861
|
ConsistentRead: true
|
|
2879
2862
|
});
|
|
2880
2863
|
return getResult.Item;
|
|
@@ -3058,7 +3041,7 @@ var Table = class {
|
|
|
3058
3041
|
try {
|
|
3059
3042
|
const result = await this.dynamoClient.delete({
|
|
3060
3043
|
TableName: params.tableName,
|
|
3061
|
-
Key:
|
|
3044
|
+
Key: this.createKeyForPrimaryIndex(keyCondition),
|
|
3062
3045
|
ConditionExpression: params.conditionExpression,
|
|
3063
3046
|
ExpressionAttributeNames: params.expressionAttributeNames,
|
|
3064
3047
|
ExpressionAttributeValues: params.expressionAttributeValues,
|
|
@@ -3085,7 +3068,7 @@ var Table = class {
|
|
|
3085
3068
|
try {
|
|
3086
3069
|
const result = await this.dynamoClient.update({
|
|
3087
3070
|
TableName: params.tableName,
|
|
3088
|
-
Key:
|
|
3071
|
+
Key: this.createKeyForPrimaryIndex(keyCondition),
|
|
3089
3072
|
UpdateExpression: params.updateExpression,
|
|
3090
3073
|
ConditionExpression: params.conditionExpression,
|
|
3091
3074
|
ExpressionAttributeNames: params.expressionAttributeNames,
|
|
@@ -3213,10 +3196,7 @@ var Table = class {
|
|
|
3213
3196
|
}
|
|
3214
3197
|
return {
|
|
3215
3198
|
DeleteRequest: {
|
|
3216
|
-
Key:
|
|
3217
|
-
[this.partitionKey]: operation.key.pk,
|
|
3218
|
-
...this.sortKey ? { [this.sortKey]: operation.key.sk } : {}
|
|
3219
|
-
}
|
|
3199
|
+
Key: this.createKeyForPrimaryIndex(operation.key)
|
|
3220
3200
|
}
|
|
3221
3201
|
};
|
|
3222
3202
|
});
|