dyno-table 2.2.1 → 2.3.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 +200 -1860
- package/dist/builders.cjs +55 -0
- package/dist/builders.d.cts +4 -0
- package/dist/builders.d.ts +4 -0
- package/dist/builders.js +2 -0
- package/dist/chunk-2EWNZOUK.js +618 -0
- package/dist/chunk-2WIBY7PZ.js +46 -0
- package/dist/chunk-7UJJ7JXM.cjs +63 -0
- package/dist/chunk-DTFJJASK.js +3200 -0
- package/dist/chunk-EODPMYPE.js +558 -0
- package/dist/chunk-KA3VPIPS.cjs +560 -0
- package/dist/chunk-NTA6GDPP.cjs +622 -0
- package/dist/chunk-PB7BBCZO.cjs +32 -0
- package/dist/chunk-QVRMYGC4.js +29 -0
- package/dist/chunk-XYL43FDX.cjs +3217 -0
- package/dist/conditions.cjs +67 -62
- package/dist/conditions.js +1 -48
- package/dist/entity.cjs +14 -625
- package/dist/entity.d.cts +2 -10
- package/dist/entity.d.ts +2 -10
- package/dist/entity.js +2 -626
- package/dist/index-2cbm07Bi.d.ts +2797 -0
- package/dist/index-DlN8G9hd.d.cts +2797 -0
- package/dist/index.cjs +111 -4460
- package/dist/index.d.cts +2 -10
- package/dist/index.d.ts +2 -10
- package/dist/index.js +5 -4442
- package/dist/standard-schema.cjs +0 -2
- package/dist/standard-schema.js +0 -2
- package/dist/table.cjs +7 -3796
- package/dist/table.d.cts +163 -12
- package/dist/table.d.ts +163 -12
- package/dist/table.js +3 -3799
- package/dist/types.cjs +0 -2
- package/dist/types.js +0 -2
- package/dist/utils.cjs +10 -30
- package/dist/utils.js +1 -31
- package/package.json +6 -66
- package/dist/batch-builder-BiQDIZ7p.d.cts +0 -398
- package/dist/batch-builder-CNsLS6sR.d.ts +0 -398
- package/dist/builder-types-BTVhQSHI.d.cts +0 -169
- package/dist/builder-types-CzuLR4Th.d.ts +0 -169
- package/dist/builders/condition-check-builder.cjs +0 -422
- package/dist/builders/condition-check-builder.cjs.map +0 -1
- package/dist/builders/condition-check-builder.d.cts +0 -153
- package/dist/builders/condition-check-builder.d.ts +0 -153
- package/dist/builders/condition-check-builder.js +0 -420
- package/dist/builders/condition-check-builder.js.map +0 -1
- package/dist/builders/delete-builder.cjs +0 -484
- package/dist/builders/delete-builder.cjs.map +0 -1
- package/dist/builders/delete-builder.d.cts +0 -211
- package/dist/builders/delete-builder.d.ts +0 -211
- package/dist/builders/delete-builder.js +0 -482
- package/dist/builders/delete-builder.js.map +0 -1
- package/dist/builders/paginator.cjs +0 -193
- package/dist/builders/paginator.cjs.map +0 -1
- package/dist/builders/paginator.d.cts +0 -155
- package/dist/builders/paginator.d.ts +0 -155
- package/dist/builders/paginator.js +0 -191
- package/dist/builders/paginator.js.map +0 -1
- package/dist/builders/put-builder.cjs +0 -554
- package/dist/builders/put-builder.cjs.map +0 -1
- package/dist/builders/put-builder.d.cts +0 -319
- package/dist/builders/put-builder.d.ts +0 -319
- package/dist/builders/put-builder.js +0 -552
- package/dist/builders/put-builder.js.map +0 -1
- package/dist/builders/query-builder.cjs +0 -757
- package/dist/builders/query-builder.cjs.map +0 -1
- package/dist/builders/query-builder.d.cts +0 -6
- package/dist/builders/query-builder.d.ts +0 -6
- package/dist/builders/query-builder.js +0 -755
- package/dist/builders/query-builder.js.map +0 -1
- package/dist/builders/transaction-builder.cjs +0 -906
- package/dist/builders/transaction-builder.cjs.map +0 -1
- package/dist/builders/transaction-builder.d.cts +0 -464
- package/dist/builders/transaction-builder.d.ts +0 -464
- package/dist/builders/transaction-builder.js +0 -904
- package/dist/builders/transaction-builder.js.map +0 -1
- package/dist/builders/update-builder.cjs +0 -668
- package/dist/builders/update-builder.cjs.map +0 -1
- package/dist/builders/update-builder.d.cts +0 -374
- package/dist/builders/update-builder.d.ts +0 -374
- package/dist/builders/update-builder.js +0 -666
- package/dist/builders/update-builder.js.map +0 -1
- package/dist/conditions.cjs.map +0 -1
- package/dist/conditions.js.map +0 -1
- package/dist/entity.cjs.map +0 -1
- package/dist/entity.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/query-builder-D3URwK9k.d.cts +0 -477
- package/dist/query-builder-cfEkU0_w.d.ts +0 -477
- package/dist/standard-schema.cjs.map +0 -1
- package/dist/standard-schema.js.map +0 -1
- package/dist/table-ClST8nkR.d.cts +0 -276
- package/dist/table-vE3cGoDy.d.ts +0 -276
- package/dist/table.cjs.map +0 -1
- package/dist/table.js.map +0 -1
- package/dist/types.cjs.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils.cjs.map +0 -1
- package/dist/utils.js.map +0 -1
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import { c as PrimaryKeyWithoutExpression, a as Condition, b as ConditionOperator } from '../conditions-CcZL0sR2.cjs';
|
|
2
|
-
import { DynamoItem } from '../types.cjs';
|
|
3
|
-
import { B as BatchBuilder } from '../batch-builder-BiQDIZ7p.cjs';
|
|
4
|
-
import { D as DeleteCommandParams } from '../builder-types-BTVhQSHI.cjs';
|
|
5
|
-
import { TransactionBuilder } from './transaction-builder.cjs';
|
|
6
|
-
import '@aws-sdk/lib-dynamodb';
|
|
7
|
-
|
|
8
|
-
interface DeleteOptions {
|
|
9
|
-
condition?: Condition;
|
|
10
|
-
returnValues?: "ALL_OLD";
|
|
11
|
-
}
|
|
12
|
-
type DeleteExecutor = (params: DeleteCommandParams) => Promise<{
|
|
13
|
-
item?: DynamoItem;
|
|
14
|
-
}>;
|
|
15
|
-
/**
|
|
16
|
-
* Builder for creating DynamoDB delete operations.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* // Simple delete
|
|
21
|
-
* const result = await new DeleteBuilder(executor, 'dinosaurs', { id: 'TREX-001' })
|
|
22
|
-
* .execute();
|
|
23
|
-
*
|
|
24
|
-
* // Conditional delete with old value retrieval
|
|
25
|
-
* const result = await new DeleteBuilder(executor, 'habitats', { id: 'PADDOCK-A' })
|
|
26
|
-
* .condition(op =>
|
|
27
|
-
* op.and([
|
|
28
|
-
* op.eq('status', 'DECOMMISSIONED'),
|
|
29
|
-
* op.eq('occupants', 0),
|
|
30
|
-
* op.lt('securityIncidents', 1)
|
|
31
|
-
* ])
|
|
32
|
-
* )
|
|
33
|
-
* .returnValues('ALL_OLD')
|
|
34
|
-
* .execute();
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
declare class DeleteBuilder {
|
|
38
|
-
private options;
|
|
39
|
-
private readonly executor;
|
|
40
|
-
private readonly tableName;
|
|
41
|
-
private readonly key;
|
|
42
|
-
constructor(executor: DeleteExecutor, tableName: string, key: PrimaryKeyWithoutExpression);
|
|
43
|
-
/**
|
|
44
|
-
* Adds a condition that must be satisfied for the delete operation to succeed.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```typescript
|
|
48
|
-
* // Ensure dinosaur can be safely removed
|
|
49
|
-
* builder.condition(op =>
|
|
50
|
-
* op.and([
|
|
51
|
-
* op.eq('status', 'SEDATED'),
|
|
52
|
-
* op.eq('location', 'MEDICAL_BAY'),
|
|
53
|
-
* op.attributeExists('lastCheckup')
|
|
54
|
-
* ])
|
|
55
|
-
* );
|
|
56
|
-
*
|
|
57
|
-
* // Verify habitat is empty
|
|
58
|
-
* builder.condition(op =>
|
|
59
|
-
* op.and([
|
|
60
|
-
* op.eq('occupants', 0),
|
|
61
|
-
* op.eq('maintenanceStatus', 'COMPLETE'),
|
|
62
|
-
* op.not(op.attributeExists('activeAlerts'))
|
|
63
|
-
* ])
|
|
64
|
-
* );
|
|
65
|
-
* ```
|
|
66
|
-
*
|
|
67
|
-
* @param condition - Either a Condition object or a callback function that builds the condition
|
|
68
|
-
* @returns The builder instance for method chaining
|
|
69
|
-
*/
|
|
70
|
-
condition<T extends DynamoItem>(condition: Condition | ((op: ConditionOperator<T>) => Condition)): DeleteBuilder;
|
|
71
|
-
/**
|
|
72
|
-
* Sets whether to return the item's attribute values before deletion.
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```ts
|
|
76
|
-
* // Archive dinosaur data before removal
|
|
77
|
-
* const result = await builder
|
|
78
|
-
* .returnValues('ALL_OLD')
|
|
79
|
-
* .execute();
|
|
80
|
-
*
|
|
81
|
-
* if (result.item) {
|
|
82
|
-
* console.log('Removed dinosaur data:', {
|
|
83
|
-
* species: result.item.species,
|
|
84
|
-
* age: result.item.age,
|
|
85
|
-
* lastLocation: result.item.location
|
|
86
|
-
* });
|
|
87
|
-
* }
|
|
88
|
-
* ```
|
|
89
|
-
*
|
|
90
|
-
* @param returnValues - Use 'ALL_OLD' to return all attributes of the deleted item
|
|
91
|
-
* @returns The builder instance for method chaining
|
|
92
|
-
*/
|
|
93
|
-
returnValues(returnValues: "ALL_OLD"): DeleteBuilder;
|
|
94
|
-
/**
|
|
95
|
-
* Generate the DynamoDB command parameters
|
|
96
|
-
*/
|
|
97
|
-
private toDynamoCommand;
|
|
98
|
-
/**
|
|
99
|
-
* Adds this delete operation to a transaction.
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* ```ts
|
|
103
|
-
* const transaction = new TransactionBuilder();
|
|
104
|
-
*
|
|
105
|
-
* // Remove dinosaur from old habitat
|
|
106
|
-
* new DeleteBuilder(executor, 'dinosaurs', { id: 'RAPTOR-001' })
|
|
107
|
-
* .condition(op => op.eq('status', 'SEDATED'))
|
|
108
|
-
* .withTransaction(transaction);
|
|
109
|
-
*
|
|
110
|
-
* // Update old habitat occupancy
|
|
111
|
-
* new UpdateBuilder(executor, 'habitats', { id: 'PADDOCK-A' })
|
|
112
|
-
* .add('occupants', -1)
|
|
113
|
-
* .withTransaction(transaction);
|
|
114
|
-
*
|
|
115
|
-
* // Execute transfer atomically
|
|
116
|
-
* await transaction.execute();
|
|
117
|
-
* ```
|
|
118
|
-
*
|
|
119
|
-
* @param transaction - The transaction builder to add this operation to
|
|
120
|
-
*/
|
|
121
|
-
withTransaction(transaction: TransactionBuilder): void;
|
|
122
|
-
/**
|
|
123
|
-
* Adds this delete operation to a batch with optional entity type information.
|
|
124
|
-
*
|
|
125
|
-
* @example Basic Usage
|
|
126
|
-
* ```ts
|
|
127
|
-
* const batch = table.batchBuilder();
|
|
128
|
-
*
|
|
129
|
-
* // Remove multiple dinosaurs in batch
|
|
130
|
-
* dinosaurRepo.delete({ id: 'old-dino-1' }).withBatch(batch);
|
|
131
|
-
* dinosaurRepo.delete({ id: 'old-dino-2' }).withBatch(batch);
|
|
132
|
-
* dinosaurRepo.delete({ id: 'old-dino-3' }).withBatch(batch);
|
|
133
|
-
*
|
|
134
|
-
* // Execute all deletions efficiently
|
|
135
|
-
* await batch.execute();
|
|
136
|
-
* ```
|
|
137
|
-
*
|
|
138
|
-
* @example Typed Usage
|
|
139
|
-
* ```ts
|
|
140
|
-
* const batch = table.batchBuilder<{
|
|
141
|
-
* User: UserEntity;
|
|
142
|
-
* Order: OrderEntity;
|
|
143
|
-
* }>();
|
|
144
|
-
*
|
|
145
|
-
* // Add operations with type information
|
|
146
|
-
* userRepo.delete({ id: 'user-1' }).withBatch(batch, 'User');
|
|
147
|
-
* orderRepo.delete({ id: 'order-1' }).withBatch(batch, 'Order');
|
|
148
|
-
*
|
|
149
|
-
* // Execute batch operations
|
|
150
|
-
* await batch.execute();
|
|
151
|
-
* ```
|
|
152
|
-
*
|
|
153
|
-
* @param batch - The batch builder to add this operation to
|
|
154
|
-
* @param entityType - Optional entity type key for type tracking
|
|
155
|
-
*/
|
|
156
|
-
withBatch<TEntities extends Record<string, DynamoItem> = Record<string, DynamoItem>, K extends keyof TEntities = keyof TEntities>(batch: BatchBuilder<TEntities>, entityType?: K): void;
|
|
157
|
-
/**
|
|
158
|
-
* Executes the delete operation against DynamoDB.
|
|
159
|
-
*
|
|
160
|
-
* @example
|
|
161
|
-
* ```ts
|
|
162
|
-
* // Delete with condition and retrieve old values
|
|
163
|
-
* const result = await new DeleteBuilder(executor, 'myTable', { id: '123' })
|
|
164
|
-
* .condition(op => op.eq('status', 'INACTIVE'))
|
|
165
|
-
* .returnValues('ALL_OLD')
|
|
166
|
-
* .execute();
|
|
167
|
-
*
|
|
168
|
-
* if (result.item) {
|
|
169
|
-
* console.log('Deleted item:', result.item);
|
|
170
|
-
* }
|
|
171
|
-
* ```
|
|
172
|
-
*
|
|
173
|
-
* @returns A promise that resolves to an object containing the deleted item's attributes (if returnValues is 'ALL_OLD')
|
|
174
|
-
*/
|
|
175
|
-
execute(): Promise<{
|
|
176
|
-
item?: DynamoItem;
|
|
177
|
-
}>;
|
|
178
|
-
/**
|
|
179
|
-
* Gets a human-readable representation of the delete command
|
|
180
|
-
* with all expression placeholders replaced by their actual values.
|
|
181
|
-
*
|
|
182
|
-
* @example
|
|
183
|
-
* ```ts
|
|
184
|
-
* const debugInfo = new DeleteBuilder(executor, 'dinosaurs', { id: 'TREX-001' })
|
|
185
|
-
* .condition(op => op.and([
|
|
186
|
-
* op.eq('status', 'SEDATED'),
|
|
187
|
-
* op.eq('location', 'MEDICAL_BAY'),
|
|
188
|
-
* op.gt('sedationLevel', 8)
|
|
189
|
-
* op.eq('version', 1),
|
|
190
|
-
* op.attributeExists('status')
|
|
191
|
-
* ]))
|
|
192
|
-
* .debug();
|
|
193
|
-
*
|
|
194
|
-
* console.log('Delete command:', debugInfo);
|
|
195
|
-
* ```
|
|
196
|
-
*
|
|
197
|
-
* @returns A readable representation of the delete command with resolved expressions
|
|
198
|
-
*/
|
|
199
|
-
debug(): {
|
|
200
|
-
raw: DeleteCommandParams;
|
|
201
|
-
readable: {
|
|
202
|
-
conditionExpression?: string;
|
|
203
|
-
updateExpression?: string;
|
|
204
|
-
filterExpression?: string;
|
|
205
|
-
keyConditionExpression?: string;
|
|
206
|
-
projectionExpression?: string;
|
|
207
|
-
};
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
export { DeleteBuilder, type DeleteOptions };
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import { c as PrimaryKeyWithoutExpression, a as Condition, b as ConditionOperator } from '../conditions-D_w7vVYG.js';
|
|
2
|
-
import { DynamoItem } from '../types.js';
|
|
3
|
-
import { B as BatchBuilder } from '../batch-builder-CNsLS6sR.js';
|
|
4
|
-
import { D as DeleteCommandParams } from '../builder-types-CzuLR4Th.js';
|
|
5
|
-
import { TransactionBuilder } from './transaction-builder.js';
|
|
6
|
-
import '@aws-sdk/lib-dynamodb';
|
|
7
|
-
|
|
8
|
-
interface DeleteOptions {
|
|
9
|
-
condition?: Condition;
|
|
10
|
-
returnValues?: "ALL_OLD";
|
|
11
|
-
}
|
|
12
|
-
type DeleteExecutor = (params: DeleteCommandParams) => Promise<{
|
|
13
|
-
item?: DynamoItem;
|
|
14
|
-
}>;
|
|
15
|
-
/**
|
|
16
|
-
* Builder for creating DynamoDB delete operations.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* // Simple delete
|
|
21
|
-
* const result = await new DeleteBuilder(executor, 'dinosaurs', { id: 'TREX-001' })
|
|
22
|
-
* .execute();
|
|
23
|
-
*
|
|
24
|
-
* // Conditional delete with old value retrieval
|
|
25
|
-
* const result = await new DeleteBuilder(executor, 'habitats', { id: 'PADDOCK-A' })
|
|
26
|
-
* .condition(op =>
|
|
27
|
-
* op.and([
|
|
28
|
-
* op.eq('status', 'DECOMMISSIONED'),
|
|
29
|
-
* op.eq('occupants', 0),
|
|
30
|
-
* op.lt('securityIncidents', 1)
|
|
31
|
-
* ])
|
|
32
|
-
* )
|
|
33
|
-
* .returnValues('ALL_OLD')
|
|
34
|
-
* .execute();
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
declare class DeleteBuilder {
|
|
38
|
-
private options;
|
|
39
|
-
private readonly executor;
|
|
40
|
-
private readonly tableName;
|
|
41
|
-
private readonly key;
|
|
42
|
-
constructor(executor: DeleteExecutor, tableName: string, key: PrimaryKeyWithoutExpression);
|
|
43
|
-
/**
|
|
44
|
-
* Adds a condition that must be satisfied for the delete operation to succeed.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```typescript
|
|
48
|
-
* // Ensure dinosaur can be safely removed
|
|
49
|
-
* builder.condition(op =>
|
|
50
|
-
* op.and([
|
|
51
|
-
* op.eq('status', 'SEDATED'),
|
|
52
|
-
* op.eq('location', 'MEDICAL_BAY'),
|
|
53
|
-
* op.attributeExists('lastCheckup')
|
|
54
|
-
* ])
|
|
55
|
-
* );
|
|
56
|
-
*
|
|
57
|
-
* // Verify habitat is empty
|
|
58
|
-
* builder.condition(op =>
|
|
59
|
-
* op.and([
|
|
60
|
-
* op.eq('occupants', 0),
|
|
61
|
-
* op.eq('maintenanceStatus', 'COMPLETE'),
|
|
62
|
-
* op.not(op.attributeExists('activeAlerts'))
|
|
63
|
-
* ])
|
|
64
|
-
* );
|
|
65
|
-
* ```
|
|
66
|
-
*
|
|
67
|
-
* @param condition - Either a Condition object or a callback function that builds the condition
|
|
68
|
-
* @returns The builder instance for method chaining
|
|
69
|
-
*/
|
|
70
|
-
condition<T extends DynamoItem>(condition: Condition | ((op: ConditionOperator<T>) => Condition)): DeleteBuilder;
|
|
71
|
-
/**
|
|
72
|
-
* Sets whether to return the item's attribute values before deletion.
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```ts
|
|
76
|
-
* // Archive dinosaur data before removal
|
|
77
|
-
* const result = await builder
|
|
78
|
-
* .returnValues('ALL_OLD')
|
|
79
|
-
* .execute();
|
|
80
|
-
*
|
|
81
|
-
* if (result.item) {
|
|
82
|
-
* console.log('Removed dinosaur data:', {
|
|
83
|
-
* species: result.item.species,
|
|
84
|
-
* age: result.item.age,
|
|
85
|
-
* lastLocation: result.item.location
|
|
86
|
-
* });
|
|
87
|
-
* }
|
|
88
|
-
* ```
|
|
89
|
-
*
|
|
90
|
-
* @param returnValues - Use 'ALL_OLD' to return all attributes of the deleted item
|
|
91
|
-
* @returns The builder instance for method chaining
|
|
92
|
-
*/
|
|
93
|
-
returnValues(returnValues: "ALL_OLD"): DeleteBuilder;
|
|
94
|
-
/**
|
|
95
|
-
* Generate the DynamoDB command parameters
|
|
96
|
-
*/
|
|
97
|
-
private toDynamoCommand;
|
|
98
|
-
/**
|
|
99
|
-
* Adds this delete operation to a transaction.
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* ```ts
|
|
103
|
-
* const transaction = new TransactionBuilder();
|
|
104
|
-
*
|
|
105
|
-
* // Remove dinosaur from old habitat
|
|
106
|
-
* new DeleteBuilder(executor, 'dinosaurs', { id: 'RAPTOR-001' })
|
|
107
|
-
* .condition(op => op.eq('status', 'SEDATED'))
|
|
108
|
-
* .withTransaction(transaction);
|
|
109
|
-
*
|
|
110
|
-
* // Update old habitat occupancy
|
|
111
|
-
* new UpdateBuilder(executor, 'habitats', { id: 'PADDOCK-A' })
|
|
112
|
-
* .add('occupants', -1)
|
|
113
|
-
* .withTransaction(transaction);
|
|
114
|
-
*
|
|
115
|
-
* // Execute transfer atomically
|
|
116
|
-
* await transaction.execute();
|
|
117
|
-
* ```
|
|
118
|
-
*
|
|
119
|
-
* @param transaction - The transaction builder to add this operation to
|
|
120
|
-
*/
|
|
121
|
-
withTransaction(transaction: TransactionBuilder): void;
|
|
122
|
-
/**
|
|
123
|
-
* Adds this delete operation to a batch with optional entity type information.
|
|
124
|
-
*
|
|
125
|
-
* @example Basic Usage
|
|
126
|
-
* ```ts
|
|
127
|
-
* const batch = table.batchBuilder();
|
|
128
|
-
*
|
|
129
|
-
* // Remove multiple dinosaurs in batch
|
|
130
|
-
* dinosaurRepo.delete({ id: 'old-dino-1' }).withBatch(batch);
|
|
131
|
-
* dinosaurRepo.delete({ id: 'old-dino-2' }).withBatch(batch);
|
|
132
|
-
* dinosaurRepo.delete({ id: 'old-dino-3' }).withBatch(batch);
|
|
133
|
-
*
|
|
134
|
-
* // Execute all deletions efficiently
|
|
135
|
-
* await batch.execute();
|
|
136
|
-
* ```
|
|
137
|
-
*
|
|
138
|
-
* @example Typed Usage
|
|
139
|
-
* ```ts
|
|
140
|
-
* const batch = table.batchBuilder<{
|
|
141
|
-
* User: UserEntity;
|
|
142
|
-
* Order: OrderEntity;
|
|
143
|
-
* }>();
|
|
144
|
-
*
|
|
145
|
-
* // Add operations with type information
|
|
146
|
-
* userRepo.delete({ id: 'user-1' }).withBatch(batch, 'User');
|
|
147
|
-
* orderRepo.delete({ id: 'order-1' }).withBatch(batch, 'Order');
|
|
148
|
-
*
|
|
149
|
-
* // Execute batch operations
|
|
150
|
-
* await batch.execute();
|
|
151
|
-
* ```
|
|
152
|
-
*
|
|
153
|
-
* @param batch - The batch builder to add this operation to
|
|
154
|
-
* @param entityType - Optional entity type key for type tracking
|
|
155
|
-
*/
|
|
156
|
-
withBatch<TEntities extends Record<string, DynamoItem> = Record<string, DynamoItem>, K extends keyof TEntities = keyof TEntities>(batch: BatchBuilder<TEntities>, entityType?: K): void;
|
|
157
|
-
/**
|
|
158
|
-
* Executes the delete operation against DynamoDB.
|
|
159
|
-
*
|
|
160
|
-
* @example
|
|
161
|
-
* ```ts
|
|
162
|
-
* // Delete with condition and retrieve old values
|
|
163
|
-
* const result = await new DeleteBuilder(executor, 'myTable', { id: '123' })
|
|
164
|
-
* .condition(op => op.eq('status', 'INACTIVE'))
|
|
165
|
-
* .returnValues('ALL_OLD')
|
|
166
|
-
* .execute();
|
|
167
|
-
*
|
|
168
|
-
* if (result.item) {
|
|
169
|
-
* console.log('Deleted item:', result.item);
|
|
170
|
-
* }
|
|
171
|
-
* ```
|
|
172
|
-
*
|
|
173
|
-
* @returns A promise that resolves to an object containing the deleted item's attributes (if returnValues is 'ALL_OLD')
|
|
174
|
-
*/
|
|
175
|
-
execute(): Promise<{
|
|
176
|
-
item?: DynamoItem;
|
|
177
|
-
}>;
|
|
178
|
-
/**
|
|
179
|
-
* Gets a human-readable representation of the delete command
|
|
180
|
-
* with all expression placeholders replaced by their actual values.
|
|
181
|
-
*
|
|
182
|
-
* @example
|
|
183
|
-
* ```ts
|
|
184
|
-
* const debugInfo = new DeleteBuilder(executor, 'dinosaurs', { id: 'TREX-001' })
|
|
185
|
-
* .condition(op => op.and([
|
|
186
|
-
* op.eq('status', 'SEDATED'),
|
|
187
|
-
* op.eq('location', 'MEDICAL_BAY'),
|
|
188
|
-
* op.gt('sedationLevel', 8)
|
|
189
|
-
* op.eq('version', 1),
|
|
190
|
-
* op.attributeExists('status')
|
|
191
|
-
* ]))
|
|
192
|
-
* .debug();
|
|
193
|
-
*
|
|
194
|
-
* console.log('Delete command:', debugInfo);
|
|
195
|
-
* ```
|
|
196
|
-
*
|
|
197
|
-
* @returns A readable representation of the delete command with resolved expressions
|
|
198
|
-
*/
|
|
199
|
-
debug(): {
|
|
200
|
-
raw: DeleteCommandParams;
|
|
201
|
-
readable: {
|
|
202
|
-
conditionExpression?: string;
|
|
203
|
-
updateExpression?: string;
|
|
204
|
-
filterExpression?: string;
|
|
205
|
-
keyConditionExpression?: string;
|
|
206
|
-
projectionExpression?: string;
|
|
207
|
-
};
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
export { DeleteBuilder, type DeleteOptions };
|