dyno-table 1.0.0 → 1.1.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/dist/table.cjs CHANGED
@@ -1980,13 +1980,21 @@ var TransactionBuilder = class {
1980
1980
  * @see DeleteBuilder for creating delete commands
1981
1981
  */
1982
1982
  deleteWithCommand(command) {
1983
- const keyCondition = this.createKeyForPrimaryIndex(command.key);
1984
- this.checkForDuplicateItem(command.tableName, keyCondition);
1983
+ let keyForDuplicateCheck;
1984
+ let keyForTransaction;
1985
+ if (typeof command.key === "object" && command.key !== null && "pk" in command.key) {
1986
+ keyForTransaction = this.createKeyForPrimaryIndex(command.key);
1987
+ keyForDuplicateCheck = keyForTransaction;
1988
+ } else {
1989
+ keyForTransaction = command.key;
1990
+ keyForDuplicateCheck = command.key;
1991
+ }
1992
+ this.checkForDuplicateItem(command.tableName, keyForDuplicateCheck);
1985
1993
  const transactionItem = {
1986
1994
  type: "Delete",
1987
1995
  params: {
1988
1996
  ...command,
1989
- key: keyCondition
1997
+ key: keyForTransaction
1990
1998
  }
1991
1999
  };
1992
2000
  this.items.push(transactionItem);
@@ -2107,13 +2115,21 @@ var TransactionBuilder = class {
2107
2115
  * @see UpdateBuilder for creating update commands
2108
2116
  */
2109
2117
  updateWithCommand(command) {
2110
- const keyCondition = this.createKeyForPrimaryIndex(command.key);
2111
- this.checkForDuplicateItem(command.tableName, keyCondition);
2118
+ let keyForDuplicateCheck;
2119
+ let keyForTransaction;
2120
+ if (typeof command.key === "object" && command.key !== null && "pk" in command.key) {
2121
+ keyForTransaction = this.createKeyForPrimaryIndex(command.key);
2122
+ keyForDuplicateCheck = keyForTransaction;
2123
+ } else {
2124
+ keyForTransaction = command.key;
2125
+ keyForDuplicateCheck = command.key;
2126
+ }
2127
+ this.checkForDuplicateItem(command.tableName, keyForDuplicateCheck);
2112
2128
  const transactionItem = {
2113
2129
  type: "Update",
2114
2130
  params: {
2115
2131
  ...command,
2116
- key: keyCondition
2132
+ key: keyForTransaction
2117
2133
  }
2118
2134
  };
2119
2135
  this.items.push(transactionItem);
@@ -2221,13 +2237,21 @@ var TransactionBuilder = class {
2221
2237
  * @see ConditionCheckBuilder for creating condition check commands
2222
2238
  */
2223
2239
  conditionCheckWithCommand(command) {
2224
- const keyCondition = this.createKeyForPrimaryIndex(command.key);
2225
- this.checkForDuplicateItem(command.tableName, keyCondition);
2240
+ let keyForDuplicateCheck;
2241
+ let keyForTransaction;
2242
+ if (typeof command.key === "object" && command.key !== null && "pk" in command.key) {
2243
+ keyForTransaction = this.createKeyForPrimaryIndex(command.key);
2244
+ keyForDuplicateCheck = keyForTransaction;
2245
+ } else {
2246
+ keyForTransaction = command.key;
2247
+ keyForDuplicateCheck = command.key;
2248
+ }
2249
+ this.checkForDuplicateItem(command.tableName, keyForDuplicateCheck);
2226
2250
  const transactionItem = {
2227
2251
  type: "ConditionCheck",
2228
2252
  params: {
2229
2253
  ...command,
2230
- key: keyCondition
2254
+ key: keyForTransaction
2231
2255
  }
2232
2256
  };
2233
2257
  this.items.push(transactionItem);
@@ -2688,10 +2712,7 @@ var GetBuilder = class {
2688
2712
  */
2689
2713
  async execute() {
2690
2714
  const expressionParams = {
2691
- expressionAttributeNames: {},
2692
- expressionAttributeValues: {},
2693
- valueCounter: { count: 0 }
2694
- };
2715
+ expressionAttributeNames: {}};
2695
2716
  const projectionExpression = Array.from(this.selectedFields).map((p) => generateAttributeName(expressionParams, p)).join(", ");
2696
2717
  const { expressionAttributeNames } = expressionParams;
2697
2718
  return this.executor({