dyno-table 1.2.0 → 1.3.1
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 +3 -6
- package/dist/{builder-types-C_PDZhnP.d.ts → builder-types-B_tCpn9F.d.ts} +2 -1
- package/dist/{builder-types-DtwbqMeF.d.cts → builder-types-DlaUSc-b.d.cts} +2 -1
- package/dist/builders/condition-check-builder.d.cts +1 -1
- package/dist/builders/condition-check-builder.d.ts +1 -1
- package/dist/builders/delete-builder.d.cts +1 -1
- package/dist/builders/delete-builder.d.ts +1 -1
- package/dist/builders/paginator.d.cts +1 -1
- package/dist/builders/paginator.d.ts +1 -1
- package/dist/builders/put-builder.cjs +8 -2
- package/dist/builders/put-builder.cjs.map +1 -1
- package/dist/builders/put-builder.d.cts +13 -6
- package/dist/builders/put-builder.d.ts +13 -6
- package/dist/builders/put-builder.js +8 -2
- package/dist/builders/put-builder.js.map +1 -1
- package/dist/builders/query-builder.d.cts +2 -2
- package/dist/builders/query-builder.d.ts +2 -2
- package/dist/builders/transaction-builder.d.cts +1 -1
- package/dist/builders/transaction-builder.d.ts +1 -1
- package/dist/builders/update-builder.d.cts +1 -1
- package/dist/builders/update-builder.d.ts +1 -1
- package/dist/entity.d.cts +3 -3
- package/dist/entity.d.ts +3 -3
- package/dist/{query-builder-Csror9Iu.d.ts → query-builder-BehSUVpp.d.ts} +1 -1
- package/dist/{query-builder-D2FM9rsu.d.cts → query-builder-DLY2lgjI.d.cts} +1 -1
- package/dist/{table-DIfupG_s.d.cts → table-BAfnBHoH.d.cts} +30 -5
- package/dist/{table-BelHPTvr.d.ts → table-BcnNHdOb.d.ts} +30 -5
- package/dist/table.cjs +55 -24
- package/dist/table.cjs.map +1 -1
- package/dist/table.d.cts +3 -3
- package/dist/table.d.ts +3 -3
- package/dist/table.js +55 -24
- package/dist/table.js.map +1 -1
- package/package.json +1 -1
package/dist/table.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import './types.cjs';
|
|
2
2
|
import './conditions-ChhQWd6z.cjs';
|
|
3
|
-
import './query-builder-
|
|
3
|
+
import './query-builder-DLY2lgjI.cjs';
|
|
4
4
|
import './builders/put-builder.cjs';
|
|
5
5
|
import './builders/delete-builder.cjs';
|
|
6
6
|
import './builders/update-builder.cjs';
|
|
7
7
|
import './builders/transaction-builder.cjs';
|
|
8
|
-
export { T as Table } from './table-
|
|
8
|
+
export { T as Table } from './table-BAfnBHoH.cjs';
|
|
9
9
|
import './builders/condition-check-builder.cjs';
|
|
10
10
|
import '@aws-sdk/lib-dynamodb';
|
|
11
11
|
import './builders/paginator.cjs';
|
|
12
|
-
import './builder-types-
|
|
12
|
+
import './builder-types-DlaUSc-b.cjs';
|
package/dist/table.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import './types.js';
|
|
2
2
|
import './conditions--ld9a78i.js';
|
|
3
|
-
import './query-builder-
|
|
3
|
+
import './query-builder-BehSUVpp.js';
|
|
4
4
|
import './builders/put-builder.js';
|
|
5
5
|
import './builders/delete-builder.js';
|
|
6
6
|
import './builders/update-builder.js';
|
|
7
7
|
import './builders/transaction-builder.js';
|
|
8
|
-
export { T as Table } from './table-
|
|
8
|
+
export { T as Table } from './table-BcnNHdOb.js';
|
|
9
9
|
import './builders/condition-check-builder.js';
|
|
10
10
|
import '@aws-sdk/lib-dynamodb';
|
|
11
11
|
import './builders/paginator.js';
|
|
12
|
-
import './builder-types-
|
|
12
|
+
import './builder-types-B_tCpn9F.js';
|
package/dist/table.js
CHANGED
|
@@ -956,7 +956,8 @@ var PutBuilder = class {
|
|
|
956
956
|
* @options
|
|
957
957
|
* - NONE: No return value
|
|
958
958
|
* - ALL_OLD: Returns the item's previous state if it existed, no read capacity units are consumed
|
|
959
|
-
* - CONSISTENT:
|
|
959
|
+
* - CONSISTENT: Performs a GET operation after the put to retrieve the item's new state
|
|
960
|
+
* - INPUT: Returns the input values that were passed to the operation
|
|
960
961
|
*
|
|
961
962
|
* @example
|
|
962
963
|
* ```ts
|
|
@@ -975,9 +976,14 @@ var PutBuilder = class {
|
|
|
975
976
|
* }
|
|
976
977
|
* });
|
|
977
978
|
* }
|
|
979
|
+
*
|
|
980
|
+
* // Return input values for create operations
|
|
981
|
+
* const createResult = await builder
|
|
982
|
+
* .returnValues('INPUT')
|
|
983
|
+
* .execute();
|
|
978
984
|
* ```
|
|
979
985
|
*
|
|
980
|
-
* @param returnValues - Use 'ALL_OLD' to return previous values
|
|
986
|
+
* @param returnValues - Use 'ALL_OLD' to return previous values, 'INPUT' to return input values, 'CONSISTENT' for fresh data, or 'NONE' (default).
|
|
981
987
|
* @returns The builder instance for method chaining
|
|
982
988
|
*/
|
|
983
989
|
returnValues(returnValues) {
|
|
@@ -2823,13 +2829,38 @@ var Table = class {
|
|
|
2823
2829
|
return primaryCondition;
|
|
2824
2830
|
}
|
|
2825
2831
|
/**
|
|
2826
|
-
* Creates a new item in the table, it will fail if the item already exists
|
|
2832
|
+
* Creates a new item in the table, it will fail if the item already exists.
|
|
2833
|
+
*
|
|
2834
|
+
* By default, this method returns the input values passed to the create operation
|
|
2835
|
+
* upon successful creation.
|
|
2836
|
+
*
|
|
2837
|
+
* You can customise the return behaviour by chaining the `.returnValues()` method:
|
|
2827
2838
|
*
|
|
2828
2839
|
* @param item The item to create
|
|
2829
|
-
* @returns A PutBuilder instance for chaining conditions and executing the
|
|
2840
|
+
* @returns A PutBuilder instance for chaining additional conditions and executing the create operation
|
|
2841
|
+
*
|
|
2842
|
+
* @example
|
|
2843
|
+
* ```ts
|
|
2844
|
+
* // Create with default behavior (returns input values)
|
|
2845
|
+
* const result = await table.create({
|
|
2846
|
+
* id: 'user-123',
|
|
2847
|
+
* name: 'John Doe',
|
|
2848
|
+
* email: 'john@example.com'
|
|
2849
|
+
* }).execute();
|
|
2850
|
+
* console.log(result); // Returns the input object
|
|
2851
|
+
*
|
|
2852
|
+
* // Create with no return value for better performance
|
|
2853
|
+
* await table.create(userData).returnValues('NONE').execute();
|
|
2854
|
+
*
|
|
2855
|
+
* // Create and get fresh data from dynamodb using a strongly consistent read
|
|
2856
|
+
* const freshData = await table.create(userData).returnValues('CONSISTENT').execute();
|
|
2857
|
+
*
|
|
2858
|
+
* // Create and get previous values (if the item was overwritten)
|
|
2859
|
+
* const oldData = await table.create(userData).returnValues('ALL_OLD').execute();
|
|
2860
|
+
* ```
|
|
2830
2861
|
*/
|
|
2831
2862
|
create(item) {
|
|
2832
|
-
return this.put(item).condition((op) => op.attributeNotExists(this.partitionKey));
|
|
2863
|
+
return this.put(item).condition((op) => op.attributeNotExists(this.partitionKey)).returnValues("INPUT");
|
|
2833
2864
|
}
|
|
2834
2865
|
get(keyCondition) {
|
|
2835
2866
|
const executor = async (params) => {
|
|
@@ -2866,10 +2897,13 @@ var Table = class {
|
|
|
2866
2897
|
ConditionExpression: params.conditionExpression,
|
|
2867
2898
|
ExpressionAttributeNames: params.expressionAttributeNames,
|
|
2868
2899
|
ExpressionAttributeValues: params.expressionAttributeValues,
|
|
2869
|
-
// CONSISTENT
|
|
2870
|
-
// response and will be
|
|
2871
|
-
ReturnValues: params.returnValues === "CONSISTENT" ? "NONE" : params.returnValues
|
|
2900
|
+
// CONSISTENT and INPUT are not valid ReturnValues for DDB, so we set NONE as we are not interested in its
|
|
2901
|
+
// response and will be handling these cases separately
|
|
2902
|
+
ReturnValues: params.returnValues === "CONSISTENT" || params.returnValues === "INPUT" ? "NONE" : params.returnValues
|
|
2872
2903
|
});
|
|
2904
|
+
if (params.returnValues === "INPUT") {
|
|
2905
|
+
return params.item;
|
|
2906
|
+
}
|
|
2873
2907
|
if (params.returnValues === "CONSISTENT") {
|
|
2874
2908
|
const getResult = await this.dynamoClient.get({
|
|
2875
2909
|
TableName: params.tableName,
|
|
@@ -3123,23 +3157,20 @@ var Table = class {
|
|
|
3123
3157
|
* @param options Optional transaction options
|
|
3124
3158
|
* @returns A promise that resolves when the transaction is complete
|
|
3125
3159
|
*/
|
|
3126
|
-
transaction(callback, options) {
|
|
3127
|
-
const
|
|
3128
|
-
|
|
3129
|
-
await this.dynamoClient.transactWrite(params);
|
|
3130
|
-
};
|
|
3131
|
-
const transaction = new TransactionBuilder(transactionExecutor, {
|
|
3132
|
-
partitionKey: this.partitionKey,
|
|
3133
|
-
sortKey: this.sortKey
|
|
3134
|
-
});
|
|
3135
|
-
if (options) {
|
|
3136
|
-
transaction.withOptions(options);
|
|
3137
|
-
}
|
|
3138
|
-
const result = await callback(transaction);
|
|
3139
|
-
await transaction.execute();
|
|
3140
|
-
return result;
|
|
3160
|
+
async transaction(callback, options) {
|
|
3161
|
+
const transactionExecutor = async (params) => {
|
|
3162
|
+
await this.dynamoClient.transactWrite(params);
|
|
3141
3163
|
};
|
|
3142
|
-
|
|
3164
|
+
const transaction = new TransactionBuilder(transactionExecutor, {
|
|
3165
|
+
partitionKey: this.partitionKey,
|
|
3166
|
+
sortKey: this.sortKey
|
|
3167
|
+
});
|
|
3168
|
+
if (options) {
|
|
3169
|
+
transaction.withOptions(options);
|
|
3170
|
+
}
|
|
3171
|
+
const result = await callback(transaction);
|
|
3172
|
+
await transaction.execute();
|
|
3173
|
+
return result;
|
|
3143
3174
|
}
|
|
3144
3175
|
/**
|
|
3145
3176
|
* Creates a condition check operation for use in transactions
|