dyno-table 1.6.0 → 1.8.0-next.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 +53 -140
- package/dist/batch-builder-BOBwOIUE.d.ts +398 -0
- package/dist/batch-builder-CKYnMRyz.d.cts +398 -0
- package/dist/{builder-types-DlaUSc-b.d.cts → builder-types-BTVhQSHI.d.cts} +55 -5
- package/dist/{builder-types-B_tCpn9F.d.ts → builder-types-CzuLR4Th.d.ts} +55 -5
- package/dist/builders/condition-check-builder.cjs +0 -13
- package/dist/builders/condition-check-builder.cjs.map +1 -1
- package/dist/builders/condition-check-builder.d.cts +1 -14
- package/dist/builders/condition-check-builder.d.ts +1 -14
- package/dist/builders/condition-check-builder.js +0 -13
- package/dist/builders/condition-check-builder.js.map +1 -1
- package/dist/builders/delete-builder.cjs +38 -0
- package/dist/builders/delete-builder.cjs.map +1 -1
- package/dist/builders/delete-builder.d.cts +37 -1
- package/dist/builders/delete-builder.d.ts +37 -1
- package/dist/builders/delete-builder.js +38 -0
- package/dist/builders/delete-builder.js.map +1 -1
- package/dist/builders/paginator.cjs +21 -27
- package/dist/builders/paginator.cjs.map +1 -1
- package/dist/builders/paginator.d.cts +3 -27
- package/dist/builders/paginator.d.ts +3 -27
- package/dist/builders/paginator.js +21 -27
- package/dist/builders/paginator.js.map +1 -1
- package/dist/builders/put-builder.cjs +39 -8
- package/dist/builders/put-builder.cjs.map +1 -1
- package/dist/builders/put-builder.d.cts +38 -9
- package/dist/builders/put-builder.d.ts +38 -9
- package/dist/builders/put-builder.js +39 -8
- package/dist/builders/put-builder.js.map +1 -1
- package/dist/builders/query-builder.cjs +115 -75
- package/dist/builders/query-builder.cjs.map +1 -1
- package/dist/builders/query-builder.d.cts +2 -2
- package/dist/builders/query-builder.d.ts +2 -2
- package/dist/builders/query-builder.js +115 -75
- package/dist/builders/query-builder.js.map +1 -1
- package/dist/builders/transaction-builder.cjs +0 -47
- package/dist/builders/transaction-builder.cjs.map +1 -1
- package/dist/builders/transaction-builder.d.cts +1 -48
- package/dist/builders/transaction-builder.d.ts +1 -48
- package/dist/builders/transaction-builder.js +0 -47
- package/dist/builders/transaction-builder.js.map +1 -1
- package/dist/builders/update-builder.cjs +2 -2
- package/dist/builders/update-builder.cjs.map +1 -1
- package/dist/builders/update-builder.d.cts +3 -3
- package/dist/builders/update-builder.d.ts +3 -3
- package/dist/builders/update-builder.js +2 -2
- package/dist/builders/update-builder.js.map +1 -1
- package/dist/conditions.cjs.map +1 -1
- package/dist/conditions.js.map +1 -1
- package/dist/entity.cjs +69 -37
- package/dist/entity.cjs.map +1 -1
- package/dist/entity.d.cts +30 -10
- package/dist/entity.d.ts +30 -10
- package/dist/entity.js +69 -37
- package/dist/entity.js.map +1 -1
- package/dist/index.cjs +661 -218
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +660 -219
- package/dist/index.js.map +1 -1
- package/dist/{query-builder-BhrR31oO.d.ts → query-builder-CaHzZmDf.d.ts} +31 -63
- package/dist/{query-builder-CbHvimBk.d.cts → query-builder-DFkxojBM.d.cts} +31 -63
- package/dist/{table-CY9byPEg.d.cts → table-CHitMHXE.d.cts} +55 -169
- package/dist/{table-Des8C2od.d.ts → table-m7DQk5dK.d.ts} +55 -169
- package/dist/table.cjs +590 -181
- package/dist/table.cjs.map +1 -1
- package/dist/table.d.cts +4 -3
- package/dist/table.d.ts +4 -3
- package/dist/table.js +590 -181
- package/dist/table.js.map +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { C as Condition, q as ConditionOperator } from './conditions-BtynAviC.js';
|
|
2
2
|
import { Paginator } from './builders/paginator.js';
|
|
3
3
|
import { DynamoItem, TableConfig, GSINames } from './types.js';
|
|
4
|
-
import { F as FilterBuilderInterface, Q as QueryBuilderInterface } from './builder-types-
|
|
4
|
+
import { F as FilterBuilderInterface, R as ResultIterator, Q as QueryBuilderInterface } from './builder-types-CzuLR4Th.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Configuration options for DynamoDB filter operations.
|
|
@@ -40,10 +40,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
40
40
|
protected selectedFields: Set<string>;
|
|
41
41
|
/**
|
|
42
42
|
* Sets the maximum number of items to return.
|
|
43
|
-
* Use this method when you need to:
|
|
44
|
-
* - Limit the number of dinosaurs returned
|
|
45
|
-
* - Control the size of habitat reports
|
|
46
|
-
* - Implement manual pagination of security logs
|
|
47
43
|
*
|
|
48
44
|
* Note: This limit applies to the items that match the key condition
|
|
49
45
|
* before any filter expressions are applied.
|
|
@@ -69,11 +65,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
69
65
|
getLimit(): number | undefined;
|
|
70
66
|
/**
|
|
71
67
|
* Specifies a Global Secondary Index (GSI) to use for the operation.
|
|
72
|
-
* Use this method when you need to:
|
|
73
|
-
* - Find dinosaurs by species or status
|
|
74
|
-
* - Search habitats by security level
|
|
75
|
-
* - Find incidents by date
|
|
76
|
-
* - List feeding schedules by time
|
|
77
68
|
*
|
|
78
69
|
* @example
|
|
79
70
|
* ```typescript
|
|
@@ -99,11 +90,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
99
90
|
useIndex<I extends GSINames<TConfig>>(indexName: I): this;
|
|
100
91
|
/**
|
|
101
92
|
* Sets whether to use strongly consistent reads for the operation.
|
|
102
|
-
* Use this method when you need to:
|
|
103
|
-
* - Get real-time dinosaur status updates
|
|
104
|
-
* - Monitor critical security systems
|
|
105
|
-
* - Track immediate habitat changes
|
|
106
|
-
* - Verify containment protocols
|
|
107
93
|
*
|
|
108
94
|
* Note:
|
|
109
95
|
* - Consistent reads are not available on GSIs
|
|
@@ -131,11 +117,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
131
117
|
consistentRead(consistentRead?: boolean): this;
|
|
132
118
|
/**
|
|
133
119
|
* Adds a filter expression to refine the operation results.
|
|
134
|
-
* Use this method when you need to:
|
|
135
|
-
* - Filter dinosaurs by behavior patterns
|
|
136
|
-
* - Find habitats with specific conditions
|
|
137
|
-
* - Search for security incidents
|
|
138
|
-
* - Monitor feeding patterns
|
|
139
120
|
*
|
|
140
121
|
* @example
|
|
141
122
|
* ```typescript
|
|
@@ -164,11 +145,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
164
145
|
filter(condition: Condition | ((op: ConditionOperator<T>) => Condition)): this;
|
|
165
146
|
/**
|
|
166
147
|
* Specifies which attributes to return in the results.
|
|
167
|
-
* Use this method when you need to:
|
|
168
|
-
* - Get specific dinosaur attributes
|
|
169
|
-
* - Retrieve habitat statistics
|
|
170
|
-
* - Monitor security metrics
|
|
171
|
-
* - Optimize response size
|
|
172
148
|
*
|
|
173
149
|
* @example
|
|
174
150
|
* ```typescript
|
|
@@ -203,11 +179,16 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
203
179
|
*
|
|
204
180
|
* @example
|
|
205
181
|
* ```typescript
|
|
206
|
-
* // Create a paginator for dinosaur records
|
|
182
|
+
* // Create a paginator for dinosaur records with specific page size
|
|
207
183
|
* const paginator = builder
|
|
208
184
|
* .filter(op => op.eq('status', 'ACTIVE'))
|
|
209
185
|
* .paginate(10);
|
|
210
186
|
*
|
|
187
|
+
* // Create a paginator with automatic DynamoDB paging (no page size limit)
|
|
188
|
+
* const autoPaginator = builder
|
|
189
|
+
* .filter(op => op.eq('status', 'ACTIVE'))
|
|
190
|
+
* .paginate();
|
|
191
|
+
*
|
|
211
192
|
* // Process pages of dinosaur results
|
|
212
193
|
* while (paginator.hasNextPage()) {
|
|
213
194
|
* const page = await paginator.getNextPage();
|
|
@@ -216,18 +197,13 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
216
197
|
* }
|
|
217
198
|
* ```
|
|
218
199
|
*
|
|
219
|
-
* @param pageSize - The number of items to return per page
|
|
200
|
+
* @param pageSize - The number of items to return per page. If not provided, DynamoDB will automatically determine page sizes.
|
|
220
201
|
* @returns A Paginator instance that manages the pagination state
|
|
221
202
|
* @see Paginator for more pagination control options
|
|
222
203
|
*/
|
|
223
|
-
paginate(pageSize
|
|
204
|
+
paginate(pageSize?: number): Paginator<T, TConfig>;
|
|
224
205
|
/**
|
|
225
206
|
* Sets the starting point using a previous lastEvaluatedKey.
|
|
226
|
-
* Use this method when you need to:
|
|
227
|
-
* - Implement manual dinosaur list pagination
|
|
228
|
-
* - Resume habitat inspection reviews
|
|
229
|
-
* - Continue security incident analysis
|
|
230
|
-
* - Store operation position between sessions
|
|
231
207
|
*
|
|
232
208
|
* Note: This method is typically used for manual pagination.
|
|
233
209
|
* For automatic pagination, use the paginate() method instead.
|
|
@@ -240,15 +216,17 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
240
216
|
* .limit(5)
|
|
241
217
|
* .execute();
|
|
242
218
|
*
|
|
243
|
-
*
|
|
219
|
+
* const lastKey = result1.getLastEvaluatedKey();
|
|
220
|
+
* if (lastKey) {
|
|
244
221
|
* // Continue listing dinosaurs
|
|
245
222
|
* const result2 = await builder
|
|
246
223
|
* .filter(op => op.eq('status', 'ACTIVE'))
|
|
247
|
-
* .startFrom(
|
|
224
|
+
* .startFrom(lastKey)
|
|
248
225
|
* .limit(5)
|
|
249
226
|
* .execute();
|
|
250
227
|
*
|
|
251
|
-
*
|
|
228
|
+
* const items = await result2.toArray();
|
|
229
|
+
* console.log('Additional dinosaurs:', items);
|
|
252
230
|
* }
|
|
253
231
|
* ```
|
|
254
232
|
*
|
|
@@ -258,11 +236,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
258
236
|
startFrom(lastEvaluatedKey: DynamoItem): this;
|
|
259
237
|
/**
|
|
260
238
|
* Creates a deep clone of this builder instance.
|
|
261
|
-
* Use this method when you need to:
|
|
262
|
-
* - Query different dinosaur statuses
|
|
263
|
-
* - Check multiple habitat conditions
|
|
264
|
-
* - Monitor various security levels
|
|
265
|
-
* - Create report templates
|
|
266
239
|
*
|
|
267
240
|
* This is particularly useful when:
|
|
268
241
|
* - Implementing pagination (used internally by paginate())
|
|
@@ -291,14 +264,11 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
291
264
|
*/
|
|
292
265
|
abstract clone(): FilterBuilderInterface<T, TConfig>;
|
|
293
266
|
/**
|
|
294
|
-
* Executes the operation against DynamoDB.
|
|
267
|
+
* Executes the operation against DynamoDB and returns a generator that behaves like an array.
|
|
295
268
|
* This method must be implemented by subclasses to handle
|
|
296
269
|
* their specific execution logic.
|
|
297
270
|
*/
|
|
298
|
-
abstract execute(): Promise<
|
|
299
|
-
items: T[];
|
|
300
|
-
lastEvaluatedKey?: DynamoItem;
|
|
301
|
-
}>;
|
|
271
|
+
abstract execute(): Promise<ResultIterator<T, TConfig>>;
|
|
302
272
|
}
|
|
303
273
|
|
|
304
274
|
/**
|
|
@@ -462,16 +432,16 @@ declare class QueryBuilder<T extends DynamoItem, TConfig extends TableConfig = T
|
|
|
462
432
|
*/
|
|
463
433
|
clone(): QueryBuilder<T, TConfig>;
|
|
464
434
|
/**
|
|
465
|
-
* Executes the query against DynamoDB.
|
|
435
|
+
* Executes the query against DynamoDB and returns a generator that behaves like an array.
|
|
466
436
|
*
|
|
467
|
-
* The
|
|
468
|
-
*
|
|
437
|
+
* The generator automatically handles pagination and provides array-like methods
|
|
438
|
+
* for processing results efficiently without loading everything into memory at once.
|
|
469
439
|
*
|
|
470
440
|
* @example
|
|
471
441
|
* ```typescript
|
|
472
442
|
* try {
|
|
473
|
-
* // Find active carnivores
|
|
474
|
-
* const
|
|
443
|
+
* // Find active carnivores with automatic pagination
|
|
444
|
+
* const results = await new QueryBuilder(executor, eq('habitatId', 'PADDOCK-A'))
|
|
475
445
|
* .useIndex('species-status-index')
|
|
476
446
|
* .filter(op =>
|
|
477
447
|
* op.and([
|
|
@@ -481,27 +451,25 @@ declare class QueryBuilder<T extends DynamoItem, TConfig extends TableConfig = T
|
|
|
481
451
|
* ])
|
|
482
452
|
* )
|
|
483
453
|
* .sortDescending()
|
|
484
|
-
* .limit(5)
|
|
485
454
|
* .execute();
|
|
486
455
|
*
|
|
487
|
-
*
|
|
488
|
-
*
|
|
489
|
-
*
|
|
490
|
-
* console.log('Additional threats detected');
|
|
456
|
+
* // Use like an array with automatic pagination
|
|
457
|
+
* for await (const dinosaur of results) {
|
|
458
|
+
* console.log(`Processing ${dinosaur.name}`);
|
|
491
459
|
* }
|
|
460
|
+
*
|
|
461
|
+
* // Or convert to array and use array methods
|
|
462
|
+
* const allItems = await results.toArray();
|
|
463
|
+
* const dangerousOnes = allItems.filter(dino => dino.aggressionLevel > 9);
|
|
464
|
+
* const totalCount = allItems.length;
|
|
492
465
|
* } catch (error) {
|
|
493
466
|
* console.error('Security scan failed:', error);
|
|
494
467
|
* }
|
|
495
468
|
* ```
|
|
496
469
|
*
|
|
497
|
-
* @returns A promise that resolves to an
|
|
498
|
-
* - items: Array of items matching the query
|
|
499
|
-
* - lastEvaluatedKey: Token for continuing the query, if more items exist
|
|
470
|
+
* @returns A promise that resolves to a ResultGenerator that behaves like an array
|
|
500
471
|
*/
|
|
501
|
-
execute(): Promise<
|
|
502
|
-
items: T[];
|
|
503
|
-
lastEvaluatedKey?: Record<string, unknown>;
|
|
504
|
-
}>;
|
|
472
|
+
execute(): Promise<ResultIterator<T, TConfig>>;
|
|
505
473
|
}
|
|
506
474
|
|
|
507
475
|
export { FilterBuilder as F, QueryBuilder as Q, type QueryOptions as a, type FilterOptions as b };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { C as Condition, q as ConditionOperator } from './conditions-3ae5znV_.cjs';
|
|
2
2
|
import { Paginator } from './builders/paginator.cjs';
|
|
3
3
|
import { DynamoItem, TableConfig, GSINames } from './types.cjs';
|
|
4
|
-
import { F as FilterBuilderInterface, Q as QueryBuilderInterface } from './builder-types-
|
|
4
|
+
import { F as FilterBuilderInterface, R as ResultIterator, Q as QueryBuilderInterface } from './builder-types-BTVhQSHI.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Configuration options for DynamoDB filter operations.
|
|
@@ -40,10 +40,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
40
40
|
protected selectedFields: Set<string>;
|
|
41
41
|
/**
|
|
42
42
|
* Sets the maximum number of items to return.
|
|
43
|
-
* Use this method when you need to:
|
|
44
|
-
* - Limit the number of dinosaurs returned
|
|
45
|
-
* - Control the size of habitat reports
|
|
46
|
-
* - Implement manual pagination of security logs
|
|
47
43
|
*
|
|
48
44
|
* Note: This limit applies to the items that match the key condition
|
|
49
45
|
* before any filter expressions are applied.
|
|
@@ -69,11 +65,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
69
65
|
getLimit(): number | undefined;
|
|
70
66
|
/**
|
|
71
67
|
* Specifies a Global Secondary Index (GSI) to use for the operation.
|
|
72
|
-
* Use this method when you need to:
|
|
73
|
-
* - Find dinosaurs by species or status
|
|
74
|
-
* - Search habitats by security level
|
|
75
|
-
* - Find incidents by date
|
|
76
|
-
* - List feeding schedules by time
|
|
77
68
|
*
|
|
78
69
|
* @example
|
|
79
70
|
* ```typescript
|
|
@@ -99,11 +90,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
99
90
|
useIndex<I extends GSINames<TConfig>>(indexName: I): this;
|
|
100
91
|
/**
|
|
101
92
|
* Sets whether to use strongly consistent reads for the operation.
|
|
102
|
-
* Use this method when you need to:
|
|
103
|
-
* - Get real-time dinosaur status updates
|
|
104
|
-
* - Monitor critical security systems
|
|
105
|
-
* - Track immediate habitat changes
|
|
106
|
-
* - Verify containment protocols
|
|
107
93
|
*
|
|
108
94
|
* Note:
|
|
109
95
|
* - Consistent reads are not available on GSIs
|
|
@@ -131,11 +117,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
131
117
|
consistentRead(consistentRead?: boolean): this;
|
|
132
118
|
/**
|
|
133
119
|
* Adds a filter expression to refine the operation results.
|
|
134
|
-
* Use this method when you need to:
|
|
135
|
-
* - Filter dinosaurs by behavior patterns
|
|
136
|
-
* - Find habitats with specific conditions
|
|
137
|
-
* - Search for security incidents
|
|
138
|
-
* - Monitor feeding patterns
|
|
139
120
|
*
|
|
140
121
|
* @example
|
|
141
122
|
* ```typescript
|
|
@@ -164,11 +145,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
164
145
|
filter(condition: Condition | ((op: ConditionOperator<T>) => Condition)): this;
|
|
165
146
|
/**
|
|
166
147
|
* Specifies which attributes to return in the results.
|
|
167
|
-
* Use this method when you need to:
|
|
168
|
-
* - Get specific dinosaur attributes
|
|
169
|
-
* - Retrieve habitat statistics
|
|
170
|
-
* - Monitor security metrics
|
|
171
|
-
* - Optimize response size
|
|
172
148
|
*
|
|
173
149
|
* @example
|
|
174
150
|
* ```typescript
|
|
@@ -203,11 +179,16 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
203
179
|
*
|
|
204
180
|
* @example
|
|
205
181
|
* ```typescript
|
|
206
|
-
* // Create a paginator for dinosaur records
|
|
182
|
+
* // Create a paginator for dinosaur records with specific page size
|
|
207
183
|
* const paginator = builder
|
|
208
184
|
* .filter(op => op.eq('status', 'ACTIVE'))
|
|
209
185
|
* .paginate(10);
|
|
210
186
|
*
|
|
187
|
+
* // Create a paginator with automatic DynamoDB paging (no page size limit)
|
|
188
|
+
* const autoPaginator = builder
|
|
189
|
+
* .filter(op => op.eq('status', 'ACTIVE'))
|
|
190
|
+
* .paginate();
|
|
191
|
+
*
|
|
211
192
|
* // Process pages of dinosaur results
|
|
212
193
|
* while (paginator.hasNextPage()) {
|
|
213
194
|
* const page = await paginator.getNextPage();
|
|
@@ -216,18 +197,13 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
216
197
|
* }
|
|
217
198
|
* ```
|
|
218
199
|
*
|
|
219
|
-
* @param pageSize - The number of items to return per page
|
|
200
|
+
* @param pageSize - The number of items to return per page. If not provided, DynamoDB will automatically determine page sizes.
|
|
220
201
|
* @returns A Paginator instance that manages the pagination state
|
|
221
202
|
* @see Paginator for more pagination control options
|
|
222
203
|
*/
|
|
223
|
-
paginate(pageSize
|
|
204
|
+
paginate(pageSize?: number): Paginator<T, TConfig>;
|
|
224
205
|
/**
|
|
225
206
|
* Sets the starting point using a previous lastEvaluatedKey.
|
|
226
|
-
* Use this method when you need to:
|
|
227
|
-
* - Implement manual dinosaur list pagination
|
|
228
|
-
* - Resume habitat inspection reviews
|
|
229
|
-
* - Continue security incident analysis
|
|
230
|
-
* - Store operation position between sessions
|
|
231
207
|
*
|
|
232
208
|
* Note: This method is typically used for manual pagination.
|
|
233
209
|
* For automatic pagination, use the paginate() method instead.
|
|
@@ -240,15 +216,17 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
240
216
|
* .limit(5)
|
|
241
217
|
* .execute();
|
|
242
218
|
*
|
|
243
|
-
*
|
|
219
|
+
* const lastKey = result1.getLastEvaluatedKey();
|
|
220
|
+
* if (lastKey) {
|
|
244
221
|
* // Continue listing dinosaurs
|
|
245
222
|
* const result2 = await builder
|
|
246
223
|
* .filter(op => op.eq('status', 'ACTIVE'))
|
|
247
|
-
* .startFrom(
|
|
224
|
+
* .startFrom(lastKey)
|
|
248
225
|
* .limit(5)
|
|
249
226
|
* .execute();
|
|
250
227
|
*
|
|
251
|
-
*
|
|
228
|
+
* const items = await result2.toArray();
|
|
229
|
+
* console.log('Additional dinosaurs:', items);
|
|
252
230
|
* }
|
|
253
231
|
* ```
|
|
254
232
|
*
|
|
@@ -258,11 +236,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
258
236
|
startFrom(lastEvaluatedKey: DynamoItem): this;
|
|
259
237
|
/**
|
|
260
238
|
* Creates a deep clone of this builder instance.
|
|
261
|
-
* Use this method when you need to:
|
|
262
|
-
* - Query different dinosaur statuses
|
|
263
|
-
* - Check multiple habitat conditions
|
|
264
|
-
* - Monitor various security levels
|
|
265
|
-
* - Create report templates
|
|
266
239
|
*
|
|
267
240
|
* This is particularly useful when:
|
|
268
241
|
* - Implementing pagination (used internally by paginate())
|
|
@@ -291,14 +264,11 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
291
264
|
*/
|
|
292
265
|
abstract clone(): FilterBuilderInterface<T, TConfig>;
|
|
293
266
|
/**
|
|
294
|
-
* Executes the operation against DynamoDB.
|
|
267
|
+
* Executes the operation against DynamoDB and returns a generator that behaves like an array.
|
|
295
268
|
* This method must be implemented by subclasses to handle
|
|
296
269
|
* their specific execution logic.
|
|
297
270
|
*/
|
|
298
|
-
abstract execute(): Promise<
|
|
299
|
-
items: T[];
|
|
300
|
-
lastEvaluatedKey?: DynamoItem;
|
|
301
|
-
}>;
|
|
271
|
+
abstract execute(): Promise<ResultIterator<T, TConfig>>;
|
|
302
272
|
}
|
|
303
273
|
|
|
304
274
|
/**
|
|
@@ -462,16 +432,16 @@ declare class QueryBuilder<T extends DynamoItem, TConfig extends TableConfig = T
|
|
|
462
432
|
*/
|
|
463
433
|
clone(): QueryBuilder<T, TConfig>;
|
|
464
434
|
/**
|
|
465
|
-
* Executes the query against DynamoDB.
|
|
435
|
+
* Executes the query against DynamoDB and returns a generator that behaves like an array.
|
|
466
436
|
*
|
|
467
|
-
* The
|
|
468
|
-
*
|
|
437
|
+
* The generator automatically handles pagination and provides array-like methods
|
|
438
|
+
* for processing results efficiently without loading everything into memory at once.
|
|
469
439
|
*
|
|
470
440
|
* @example
|
|
471
441
|
* ```typescript
|
|
472
442
|
* try {
|
|
473
|
-
* // Find active carnivores
|
|
474
|
-
* const
|
|
443
|
+
* // Find active carnivores with automatic pagination
|
|
444
|
+
* const results = await new QueryBuilder(executor, eq('habitatId', 'PADDOCK-A'))
|
|
475
445
|
* .useIndex('species-status-index')
|
|
476
446
|
* .filter(op =>
|
|
477
447
|
* op.and([
|
|
@@ -481,27 +451,25 @@ declare class QueryBuilder<T extends DynamoItem, TConfig extends TableConfig = T
|
|
|
481
451
|
* ])
|
|
482
452
|
* )
|
|
483
453
|
* .sortDescending()
|
|
484
|
-
* .limit(5)
|
|
485
454
|
* .execute();
|
|
486
455
|
*
|
|
487
|
-
*
|
|
488
|
-
*
|
|
489
|
-
*
|
|
490
|
-
* console.log('Additional threats detected');
|
|
456
|
+
* // Use like an array with automatic pagination
|
|
457
|
+
* for await (const dinosaur of results) {
|
|
458
|
+
* console.log(`Processing ${dinosaur.name}`);
|
|
491
459
|
* }
|
|
460
|
+
*
|
|
461
|
+
* // Or convert to array and use array methods
|
|
462
|
+
* const allItems = await results.toArray();
|
|
463
|
+
* const dangerousOnes = allItems.filter(dino => dino.aggressionLevel > 9);
|
|
464
|
+
* const totalCount = allItems.length;
|
|
492
465
|
* } catch (error) {
|
|
493
466
|
* console.error('Security scan failed:', error);
|
|
494
467
|
* }
|
|
495
468
|
* ```
|
|
496
469
|
*
|
|
497
|
-
* @returns A promise that resolves to an
|
|
498
|
-
* - items: Array of items matching the query
|
|
499
|
-
* - lastEvaluatedKey: Token for continuing the query, if more items exist
|
|
470
|
+
* @returns A promise that resolves to a ResultGenerator that behaves like an array
|
|
500
471
|
*/
|
|
501
|
-
execute(): Promise<
|
|
502
|
-
items: T[];
|
|
503
|
-
lastEvaluatedKey?: Record<string, unknown>;
|
|
504
|
-
}>;
|
|
472
|
+
execute(): Promise<ResultIterator<T, TConfig>>;
|
|
505
473
|
}
|
|
506
474
|
|
|
507
475
|
export { FilterBuilder as F, QueryBuilder as Q, type QueryOptions as a, type FilterOptions as b };
|