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
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { C as Condition, P as PrimaryKeyWithoutExpression, c as Path, d as PathType, b as ConditionOperator } from '../conditions--ld9a78i.js';
|
|
2
|
+
import { TransactionBuilder } from './transaction-builder.js';
|
|
3
|
+
import { U as UpdateCommandParams } from '../builder-types-C_PDZhnP.js';
|
|
4
|
+
import { DynamoItem } from '../types.js';
|
|
5
|
+
import '@aws-sdk/lib-dynamodb';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Configuration options for DynamoDB update operations.
|
|
9
|
+
*/
|
|
10
|
+
interface UpdateOptions {
|
|
11
|
+
/** Optional condition that must be satisfied for the update to succeed */
|
|
12
|
+
condition?: Condition;
|
|
13
|
+
/** Determines which item attributes to include in the response */
|
|
14
|
+
returnValues?: "ALL_NEW" | "UPDATED_NEW" | "ALL_OLD" | "UPDATED_OLD" | "NONE";
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Function type for executing DynamoDB update operations.
|
|
18
|
+
* @typeParam T - The type of the item being updated
|
|
19
|
+
*/
|
|
20
|
+
type UpdateExecutor<T extends DynamoItem> = (params: UpdateCommandParams) => Promise<{
|
|
21
|
+
item?: T;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Represents a single update action within an update operation.
|
|
25
|
+
* Each action modifies the item in a specific way:
|
|
26
|
+
* - SET: Modify or add attributes
|
|
27
|
+
* - REMOVE: Delete attributes
|
|
28
|
+
* - ADD: Update numbers and sets
|
|
29
|
+
* - DELETE: Remove elements from a set
|
|
30
|
+
*/
|
|
31
|
+
type UpdateAction = {
|
|
32
|
+
/** The type of update action */
|
|
33
|
+
type: "SET" | "REMOVE" | "ADD" | "DELETE";
|
|
34
|
+
/** The attribute path to update */
|
|
35
|
+
path: string;
|
|
36
|
+
/** The value to use in the update (not used for REMOVE actions) */
|
|
37
|
+
value?: unknown;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Type utility to get the element type of a set.
|
|
41
|
+
* Extracts the element type from either a Set or Array type.
|
|
42
|
+
* @typeParam T - The set or array type
|
|
43
|
+
*/
|
|
44
|
+
type SetElementType<T> = T extends Set<infer U> ? U : T extends Array<infer U> ? U : never;
|
|
45
|
+
/**
|
|
46
|
+
* Type utility to get the element type from a path that points to a set.
|
|
47
|
+
* Combines PathType and SetElementType to get the element type at a specific path.
|
|
48
|
+
* @typeParam T - The type of the item
|
|
49
|
+
* @typeParam K - The path within the item
|
|
50
|
+
*/
|
|
51
|
+
type PathSetElementType<T, K extends Path<T>> = SetElementType<PathType<T, K>>;
|
|
52
|
+
/**
|
|
53
|
+
* Builder for creating DynamoDB update operations.
|
|
54
|
+
*
|
|
55
|
+
* The builder supports all DynamoDB update operations:
|
|
56
|
+
* - SET: Modify or add attributes
|
|
57
|
+
* - REMOVE: Delete attributes
|
|
58
|
+
* - ADD: Update numbers and sets
|
|
59
|
+
* - DELETE: Remove elements from a set
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* // Simple update
|
|
64
|
+
* const result = await new UpdateBuilder(executor, 'dinosaurs', { id: 'TREX-001' })
|
|
65
|
+
* .set('status', 'HUNTING')
|
|
66
|
+
* .set('lastFed', new Date().toISOString())
|
|
67
|
+
* .execute();
|
|
68
|
+
*
|
|
69
|
+
* // Complex update with multiple operations
|
|
70
|
+
* const result = await new UpdateBuilder(executor, 'habitats', { id: 'PADDOCK-A' })
|
|
71
|
+
* .set({
|
|
72
|
+
* status: 'OCCUPIED',
|
|
73
|
+
* occupants: 3,
|
|
74
|
+
* 'metadata.lastInspection': new Date().toISOString()
|
|
75
|
+
* })
|
|
76
|
+
* .add('securityBreaches', 1)
|
|
77
|
+
* .deleteElementsFromSet('suitableDinosaurs', ['VELOCIRAPTOR'])
|
|
78
|
+
* .condition(op => op.gt('securityLevel', 8))
|
|
79
|
+
* .returnValues('ALL_NEW')
|
|
80
|
+
* .execute();
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @typeParam T - The type of item being updated
|
|
84
|
+
*/
|
|
85
|
+
declare class UpdateBuilder<T extends DynamoItem> {
|
|
86
|
+
private updates;
|
|
87
|
+
private options;
|
|
88
|
+
private readonly executor;
|
|
89
|
+
private readonly tableName;
|
|
90
|
+
private readonly key;
|
|
91
|
+
constructor(executor: UpdateExecutor<T>, tableName: string, key: PrimaryKeyWithoutExpression);
|
|
92
|
+
/**
|
|
93
|
+
* Sets multiple attributes of an item using an object.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* // Update multiple attributes
|
|
98
|
+
* builder.set({
|
|
99
|
+
* species: 'Tyrannosaurus Rex',
|
|
100
|
+
* height: 20,
|
|
101
|
+
* diet: 'CARNIVORE',
|
|
102
|
+
* 'stats.threatLevel': 10
|
|
103
|
+
* });
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
set(values: Partial<T>): UpdateBuilder<T>;
|
|
107
|
+
/**
|
|
108
|
+
* Sets a single attribute to a specific value.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* // Set simple attributes
|
|
113
|
+
* builder
|
|
114
|
+
* .set('status', 'SLEEPING')
|
|
115
|
+
* .set('lastFeeding', new Date().toISOString());
|
|
116
|
+
*
|
|
117
|
+
* // Set nested attributes
|
|
118
|
+
* builder
|
|
119
|
+
* .set('location.zone', 'RESTRICTED')
|
|
120
|
+
* .set('stats.health', 100);
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
set<K extends Path<T>>(path: K, value: PathType<T, K>): UpdateBuilder<T>;
|
|
124
|
+
/**
|
|
125
|
+
* Removes an attribute from the item.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* // Remove simple attributes
|
|
130
|
+
* builder
|
|
131
|
+
* .remove('temporaryTag')
|
|
132
|
+
* .remove('previousLocation');
|
|
133
|
+
*
|
|
134
|
+
* // Remove nested attributes
|
|
135
|
+
* builder
|
|
136
|
+
* .remove('metadata.testData')
|
|
137
|
+
* .remove('stats.experimentalMetrics');
|
|
138
|
+
* ```
|
|
139
|
+
*
|
|
140
|
+
* @param path - The path to the attribute to remove
|
|
141
|
+
* @returns The builder instance for method chaining
|
|
142
|
+
*/
|
|
143
|
+
remove<K extends Path<T>>(path: K): this;
|
|
144
|
+
/**
|
|
145
|
+
* Adds a value to a number attribute or adds elements to a set.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* // Increment counters
|
|
150
|
+
* builder
|
|
151
|
+
* .add('escapeAttempts', 1)
|
|
152
|
+
* .add('feedingCount', 1);
|
|
153
|
+
*
|
|
154
|
+
* // Add to sets
|
|
155
|
+
* builder
|
|
156
|
+
* .add('knownBehaviors', new Set(['PACK_HUNTING', 'AMBUSH_TACTICS']))
|
|
157
|
+
* .add('visitedZones', new Set(['ZONE_A', 'ZONE_B']));
|
|
158
|
+
* ```
|
|
159
|
+
*
|
|
160
|
+
* @param path - The path to the attribute to update
|
|
161
|
+
* @param value - The value to add (number or set)
|
|
162
|
+
* @returns The builder instance for method chaining
|
|
163
|
+
*/
|
|
164
|
+
add<K extends Path<T>>(path: K, value: PathType<T, K>): this;
|
|
165
|
+
/**
|
|
166
|
+
* Removes elements from a set attribute.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* // Remove from sets using arrays
|
|
171
|
+
* builder.deleteElementsFromSet(
|
|
172
|
+
* 'allowedHabitats',
|
|
173
|
+
* ['JUNGLE', 'COASTAL']
|
|
174
|
+
* );
|
|
175
|
+
*
|
|
176
|
+
* // Remove from sets using Set DynamoItems
|
|
177
|
+
* builder.deleteElementsFromSet(
|
|
178
|
+
* 'knownBehaviors',
|
|
179
|
+
* new Set(['NOCTURNAL', 'TERRITORIAL'])
|
|
180
|
+
* );
|
|
181
|
+
*
|
|
182
|
+
* // Remove from nested sets
|
|
183
|
+
* builder.deleteElementsFromSet(
|
|
184
|
+
* 'stats.compatibleSpecies',
|
|
185
|
+
* ['VELOCIRAPTOR', 'DILOPHOSAURUS']
|
|
186
|
+
* );
|
|
187
|
+
* ```
|
|
188
|
+
*
|
|
189
|
+
* @param path - The path to the set attribute
|
|
190
|
+
* @param value - Elements to remove (array or Set)
|
|
191
|
+
* @returns The builder instance for method chaining
|
|
192
|
+
*/
|
|
193
|
+
deleteElementsFromSet<K extends Path<T>>(path: K, value: PathSetElementType<T, K>[] | Set<PathSetElementType<T, K>>): this;
|
|
194
|
+
/**
|
|
195
|
+
* Adds a condition that must be satisfied for the update to succeed.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```typescript
|
|
199
|
+
* // Simple condition
|
|
200
|
+
* builder.condition(op =>
|
|
201
|
+
* op.eq('status', 'ACTIVE')
|
|
202
|
+
* );
|
|
203
|
+
*
|
|
204
|
+
* // Health check condition
|
|
205
|
+
* builder.condition(op =>
|
|
206
|
+
* op.and([
|
|
207
|
+
* op.gt('health', 50),
|
|
208
|
+
* op.eq('status', 'HUNTING')
|
|
209
|
+
* ])
|
|
210
|
+
* );
|
|
211
|
+
*
|
|
212
|
+
* // Complex security condition
|
|
213
|
+
* builder.condition(op =>
|
|
214
|
+
* op.and([
|
|
215
|
+
* op.attributeExists('securitySystem'),
|
|
216
|
+
* op.eq('containmentStatus', 'SECURE'),
|
|
217
|
+
* op.lt('aggressionLevel', 8)
|
|
218
|
+
* ])
|
|
219
|
+
* );
|
|
220
|
+
*
|
|
221
|
+
* // Version check (optimistic locking)
|
|
222
|
+
* builder.condition(op =>
|
|
223
|
+
* op.eq('version', currentVersion)
|
|
224
|
+
* );
|
|
225
|
+
* ```
|
|
226
|
+
*
|
|
227
|
+
* @param condition - Either a Condition DynamoItem or a callback function that builds the condition
|
|
228
|
+
* @returns The builder instance for method chaining
|
|
229
|
+
*/
|
|
230
|
+
condition(condition: Condition | ((op: ConditionOperator<T>) => Condition)): this;
|
|
231
|
+
/**
|
|
232
|
+
* Sets which item attributes to include in the response.
|
|
233
|
+
*
|
|
234
|
+
* Available options:
|
|
235
|
+
* - ALL_NEW: All attributes after the update
|
|
236
|
+
* - UPDATED_NEW: Only updated attributes, new values
|
|
237
|
+
* - ALL_OLD: All attributes before the update
|
|
238
|
+
* - UPDATED_OLD: Only updated attributes, old values
|
|
239
|
+
* - NONE: No attributes returned (default)
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```typescript
|
|
243
|
+
* // Get complete updated dinosaur
|
|
244
|
+
* const result = await builder
|
|
245
|
+
* .set('status', 'SLEEPING')
|
|
246
|
+
* .returnValues('ALL_NEW')
|
|
247
|
+
* .execute();
|
|
248
|
+
*
|
|
249
|
+
* // Track specific attribute changes
|
|
250
|
+
* const result = await builder
|
|
251
|
+
* .set({
|
|
252
|
+
* 'stats.health': 100,
|
|
253
|
+
* 'stats.energy': 95
|
|
254
|
+
* })
|
|
255
|
+
* .returnValues('UPDATED_OLD')
|
|
256
|
+
* .execute();
|
|
257
|
+
*
|
|
258
|
+
* if (result.item) {
|
|
259
|
+
* console.log('Previous health:', result.item.stats?.health);
|
|
260
|
+
* }
|
|
261
|
+
* ```
|
|
262
|
+
*
|
|
263
|
+
* @param returnValues - Which attributes to return in the response
|
|
264
|
+
* @returns The builder instance for method chaining
|
|
265
|
+
*/
|
|
266
|
+
returnValues(returnValues: "ALL_NEW" | "UPDATED_NEW" | "ALL_OLD" | "UPDATED_OLD" | "NONE"): this;
|
|
267
|
+
/**
|
|
268
|
+
* Generate the DynamoDB command parameters
|
|
269
|
+
*/
|
|
270
|
+
toDynamoCommand(): UpdateCommandParams;
|
|
271
|
+
/**
|
|
272
|
+
* Adds this update operation to a transaction.
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* ```typescript
|
|
276
|
+
* const transaction = new TransactionBuilder(executor);
|
|
277
|
+
*
|
|
278
|
+
* // Update dinosaur status and habitat occupancy atomically
|
|
279
|
+
* new UpdateBuilder(executor, 'dinosaurs', { id: 'TREX-001' })
|
|
280
|
+
* .set('location', 'PADDOCK_A')
|
|
281
|
+
* .set('status', 'CONTAINED')
|
|
282
|
+
* .withTransaction(transaction);
|
|
283
|
+
*
|
|
284
|
+
* new UpdateBuilder(executor, 'habitats', { id: 'PADDOCK-A' })
|
|
285
|
+
* .add('occupants', 1)
|
|
286
|
+
* .set('lastOccupied', new Date().toISOString())
|
|
287
|
+
* .withTransaction(transaction);
|
|
288
|
+
*
|
|
289
|
+
* // Execute all operations atomically
|
|
290
|
+
* await transaction.execute();
|
|
291
|
+
* ```
|
|
292
|
+
*
|
|
293
|
+
* @param transaction - The transaction builder to add this operation to
|
|
294
|
+
* @returns The builder instance for method chaining
|
|
295
|
+
*/
|
|
296
|
+
withTransaction(transaction: TransactionBuilder): void;
|
|
297
|
+
/**
|
|
298
|
+
* Gets a human-readable representation of the update command.
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* ```typescript
|
|
302
|
+
* // Create complex update
|
|
303
|
+
* const builder = new UpdateBuilder(executor, 'dinosaurs', { id: 'RAPTOR-001' })
|
|
304
|
+
* .set({
|
|
305
|
+
* status: 'HUNTING',
|
|
306
|
+
* 'stats.health': 95,
|
|
307
|
+
* 'behavior.lastObserved': new Date().toISOString()
|
|
308
|
+
* })
|
|
309
|
+
* .add('huntingSuccesses', 1)
|
|
310
|
+
* .condition(op => op.gt('health', 50));
|
|
311
|
+
*
|
|
312
|
+
* // Debug the update
|
|
313
|
+
* const debugInfo = builder.debug();
|
|
314
|
+
* console.log('Update operation:', debugInfo);
|
|
315
|
+
* ```
|
|
316
|
+
*
|
|
317
|
+
* @returns A readable representation of the update command with resolved expressions
|
|
318
|
+
*/
|
|
319
|
+
debug(): DynamoItem;
|
|
320
|
+
/**
|
|
321
|
+
* Executes the update operation against DynamoDB.
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* ```typescript
|
|
325
|
+
* try {
|
|
326
|
+
* // Update dinosaur status with conditions
|
|
327
|
+
* const result = await new UpdateBuilder(executor, 'dinosaurs', { id: 'TREX-001' })
|
|
328
|
+
* .set({
|
|
329
|
+
* status: 'FEEDING',
|
|
330
|
+
* lastMeal: new Date().toISOString(),
|
|
331
|
+
* 'stats.hunger': 0
|
|
332
|
+
* })
|
|
333
|
+
* .add('feedingCount', 1)
|
|
334
|
+
* .condition(op =>
|
|
335
|
+
* op.and([
|
|
336
|
+
* op.gt('stats.hunger', 80),
|
|
337
|
+
* op.eq('status', 'HUNTING')
|
|
338
|
+
* ])
|
|
339
|
+
* )
|
|
340
|
+
* .returnValues('ALL_NEW')
|
|
341
|
+
* .execute();
|
|
342
|
+
*
|
|
343
|
+
* if (result.item) {
|
|
344
|
+
* console.log('Updated dinosaur:', result.item);
|
|
345
|
+
* }
|
|
346
|
+
* } catch (error) {
|
|
347
|
+
* // Handle condition check failure
|
|
348
|
+
* console.error('Failed to update dinosaur:', error);
|
|
349
|
+
* // Check if dinosaur wasn't hungry enough
|
|
350
|
+
* if (error.name === 'ConditionalCheckFailedException') {
|
|
351
|
+
* console.log('Dinosaur not ready for feeding');
|
|
352
|
+
* }
|
|
353
|
+
* }
|
|
354
|
+
* ```
|
|
355
|
+
*
|
|
356
|
+
* @returns A promise that resolves to an DynamoItem containing the updated item (if returnValues is set)
|
|
357
|
+
* @throws {ConditionalCheckFailedException} If the condition check fails
|
|
358
|
+
* @throws {Error} If the update operation fails for other reasons
|
|
359
|
+
*/
|
|
360
|
+
execute(): Promise<{
|
|
361
|
+
item?: T;
|
|
362
|
+
}>;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
export { type UpdateAction, UpdateBuilder, type UpdateOptions };
|
|
@@ -238,10 +238,6 @@ var UpdateBuilder = class {
|
|
|
238
238
|
}
|
|
239
239
|
/**
|
|
240
240
|
* Removes an attribute from the item.
|
|
241
|
-
* Use this method when you need to:
|
|
242
|
-
* - Delete attributes completely
|
|
243
|
-
* - Remove nested attributes
|
|
244
|
-
* - Clean up deprecated fields
|
|
245
241
|
*
|
|
246
242
|
* @example
|
|
247
243
|
* ```typescript
|
|
@@ -268,10 +264,6 @@ var UpdateBuilder = class {
|
|
|
268
264
|
}
|
|
269
265
|
/**
|
|
270
266
|
* Adds a value to a number attribute or adds elements to a set.
|
|
271
|
-
* Use this method when you need to:
|
|
272
|
-
* - Increment counters
|
|
273
|
-
* - Add elements to a set atomically
|
|
274
|
-
* - Update numerical statistics
|
|
275
267
|
*
|
|
276
268
|
* @example
|
|
277
269
|
* ```typescript
|
|
@@ -300,10 +292,6 @@ var UpdateBuilder = class {
|
|
|
300
292
|
}
|
|
301
293
|
/**
|
|
302
294
|
* Removes elements from a set attribute.
|
|
303
|
-
* Use this method when you need to:
|
|
304
|
-
* - Remove specific elements from a set
|
|
305
|
-
* - Update set-based attributes atomically
|
|
306
|
-
* - Maintain set membership
|
|
307
295
|
*
|
|
308
296
|
* @example
|
|
309
297
|
* ```typescript
|
|
@@ -313,7 +301,7 @@ var UpdateBuilder = class {
|
|
|
313
301
|
* ['JUNGLE', 'COASTAL']
|
|
314
302
|
* );
|
|
315
303
|
*
|
|
316
|
-
* // Remove from sets using Set
|
|
304
|
+
* // Remove from sets using Set DynamoItems
|
|
317
305
|
* builder.deleteElementsFromSet(
|
|
318
306
|
* 'knownBehaviors',
|
|
319
307
|
* new Set(['NOCTURNAL', 'TERRITORIAL'])
|
|
@@ -346,11 +334,6 @@ var UpdateBuilder = class {
|
|
|
346
334
|
}
|
|
347
335
|
/**
|
|
348
336
|
* Adds a condition that must be satisfied for the update to succeed.
|
|
349
|
-
* Use this method when you need to:
|
|
350
|
-
* - Implement optimistic locking
|
|
351
|
-
* - Ensure item state before update
|
|
352
|
-
* - Validate business rules
|
|
353
|
-
* - Prevent concurrent modifications
|
|
354
337
|
*
|
|
355
338
|
* @example
|
|
356
339
|
* ```typescript
|
|
@@ -382,7 +365,7 @@ var UpdateBuilder = class {
|
|
|
382
365
|
* );
|
|
383
366
|
* ```
|
|
384
367
|
*
|
|
385
|
-
* @param condition - Either a Condition
|
|
368
|
+
* @param condition - Either a Condition DynamoItem or a callback function that builds the condition
|
|
386
369
|
* @returns The builder instance for method chaining
|
|
387
370
|
*/
|
|
388
371
|
condition(condition) {
|
|
@@ -411,11 +394,6 @@ var UpdateBuilder = class {
|
|
|
411
394
|
}
|
|
412
395
|
/**
|
|
413
396
|
* Sets which item attributes to include in the response.
|
|
414
|
-
* Use this method when you need to:
|
|
415
|
-
* - Get the complete updated item
|
|
416
|
-
* - Track changes to specific attributes
|
|
417
|
-
* - Compare old and new values
|
|
418
|
-
* - Monitor attribute modifications
|
|
419
397
|
*
|
|
420
398
|
* Available options:
|
|
421
399
|
* - ALL_NEW: All attributes after the update
|
|
@@ -543,10 +521,6 @@ var UpdateBuilder = class {
|
|
|
543
521
|
}
|
|
544
522
|
/**
|
|
545
523
|
* Adds this update operation to a transaction.
|
|
546
|
-
* Use this method when you need to:
|
|
547
|
-
* - Update items as part of a larger transaction
|
|
548
|
-
* - Ensure multiple updates are atomic
|
|
549
|
-
* - Coordinate updates across multiple items
|
|
550
524
|
*
|
|
551
525
|
* @example
|
|
552
526
|
* ```typescript
|
|
@@ -576,11 +550,6 @@ var UpdateBuilder = class {
|
|
|
576
550
|
}
|
|
577
551
|
/**
|
|
578
552
|
* Gets a human-readable representation of the update command.
|
|
579
|
-
* Use this method when you need to:
|
|
580
|
-
* - Debug complex update expressions
|
|
581
|
-
* - Verify attribute names and values
|
|
582
|
-
* - Log update operations
|
|
583
|
-
* - Troubleshoot condition expressions
|
|
584
553
|
*
|
|
585
554
|
* @example
|
|
586
555
|
* ```typescript
|
|
@@ -607,10 +576,6 @@ var UpdateBuilder = class {
|
|
|
607
576
|
}
|
|
608
577
|
/**
|
|
609
578
|
* Executes the update operation against DynamoDB.
|
|
610
|
-
* Use this method when you need to:
|
|
611
|
-
* - Apply updates immediately
|
|
612
|
-
* - Get the updated item values
|
|
613
|
-
* - Handle conditional update failures
|
|
614
579
|
*
|
|
615
580
|
* @example
|
|
616
581
|
* ```typescript
|
|
@@ -645,7 +610,7 @@ var UpdateBuilder = class {
|
|
|
645
610
|
* }
|
|
646
611
|
* ```
|
|
647
612
|
*
|
|
648
|
-
* @returns A promise that resolves to an
|
|
613
|
+
* @returns A promise that resolves to an DynamoItem containing the updated item (if returnValues is set)
|
|
649
614
|
* @throws {ConditionalCheckFailedException} If the condition check fails
|
|
650
615
|
* @throws {Error} If the update operation fails for other reasons
|
|
651
616
|
*/
|