dyno-table 2.2.1 → 2.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 +187 -1865
- 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,477 +0,0 @@
|
|
|
1
|
-
import { a as Condition, b as ConditionOperator, s as Path } from './conditions-D_w7vVYG.js';
|
|
2
|
-
import { DynamoItem, TableConfig, GSINames } from './types.js';
|
|
3
|
-
import { F as FilterBuilderInterface, R as ResultIterator, Q as QueryBuilderInterface } from './builder-types-CzuLR4Th.js';
|
|
4
|
-
import { Paginator } from './builders/paginator.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Configuration options for DynamoDB filter operations.
|
|
8
|
-
* These are common options shared between query and scan operations.
|
|
9
|
-
*/
|
|
10
|
-
interface FilterOptions {
|
|
11
|
-
/** Filter conditions applied to results */
|
|
12
|
-
filter?: Condition;
|
|
13
|
-
/** Maximum number of items to return */
|
|
14
|
-
limit?: number;
|
|
15
|
-
/** Name of the Global Secondary Index to use */
|
|
16
|
-
indexName?: string;
|
|
17
|
-
/** Whether to use strongly consistent reads */
|
|
18
|
-
consistentRead?: boolean;
|
|
19
|
-
/** List of attributes to return in the result */
|
|
20
|
-
projection?: string[];
|
|
21
|
-
/** Token for starting the operation from a specific point */
|
|
22
|
-
lastEvaluatedKey?: DynamoItem;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Abstract base builder for creating DynamoDB filter operations.
|
|
26
|
-
* This class provides common functionality for both Query and Scan operations.
|
|
27
|
-
*
|
|
28
|
-
* The builder supports:
|
|
29
|
-
* - Type-safe GSI selection
|
|
30
|
-
* - Complex filter conditions
|
|
31
|
-
* - Pagination
|
|
32
|
-
* - Consistent reads
|
|
33
|
-
* - Attribute projection
|
|
34
|
-
*
|
|
35
|
-
* @typeParam T - The type of items being filtered
|
|
36
|
-
* @typeParam TConfig - The table configuration type for type-safe GSI selection
|
|
37
|
-
*/
|
|
38
|
-
declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends TableConfig = TableConfig> implements FilterBuilderInterface<T, TConfig> {
|
|
39
|
-
protected options: FilterOptions;
|
|
40
|
-
protected selectedFields: Set<string>;
|
|
41
|
-
/**
|
|
42
|
-
* Sets the maximum number of items to return.
|
|
43
|
-
*
|
|
44
|
-
* Note: This limit applies to the items that match the key condition
|
|
45
|
-
* before any filter expressions are applied.
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```typescript
|
|
49
|
-
* // Get first 10 dinosaurs
|
|
50
|
-
* const result = await builder
|
|
51
|
-
* .limit(10)
|
|
52
|
-
* .execute();
|
|
53
|
-
* ```
|
|
54
|
-
*
|
|
55
|
-
* @param limit - Maximum number of items to return
|
|
56
|
-
* @returns The builder instance for method chaining
|
|
57
|
-
*/
|
|
58
|
-
limit(limit: number): this;
|
|
59
|
-
/**
|
|
60
|
-
* Gets the current limit set on the operation.
|
|
61
|
-
* This is used internally by the paginator to manage result sets.
|
|
62
|
-
*
|
|
63
|
-
* @returns The current limit or undefined if no limit is set
|
|
64
|
-
*/
|
|
65
|
-
getLimit(): number | undefined;
|
|
66
|
-
/**
|
|
67
|
-
* Specifies a Global Secondary Index (GSI) to use for the operation.
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```typescript
|
|
71
|
-
* // Find all dinosaurs of a specific species
|
|
72
|
-
* builder
|
|
73
|
-
* .useIndex('species-status-index')
|
|
74
|
-
* .filter(op => op.eq('status', 'ACTIVE'));
|
|
75
|
-
*
|
|
76
|
-
* // Search high-security habitats
|
|
77
|
-
* builder
|
|
78
|
-
* .useIndex('security-level-index')
|
|
79
|
-
* .filter(op =>
|
|
80
|
-
* op.and([
|
|
81
|
-
* op.gt('securityLevel', 8),
|
|
82
|
-
* op.eq('status', 'OPERATIONAL')
|
|
83
|
-
* ])
|
|
84
|
-
* );
|
|
85
|
-
* ```
|
|
86
|
-
*
|
|
87
|
-
* @param indexName - The name of the GSI to use (type-safe based on table configuration)
|
|
88
|
-
* @returns The builder instance for method chaining
|
|
89
|
-
*/
|
|
90
|
-
useIndex<I extends GSINames<TConfig>>(indexName: I): this;
|
|
91
|
-
/**
|
|
92
|
-
* Sets whether to use strongly consistent reads for the operation.
|
|
93
|
-
*
|
|
94
|
-
* Note:
|
|
95
|
-
* - Consistent reads are not available on GSIs
|
|
96
|
-
* - Consistent reads consume twice the throughput
|
|
97
|
-
* - Default is eventually consistent reads
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* ```typescript
|
|
101
|
-
* // Check immediate dinosaur status
|
|
102
|
-
* const result = await builder
|
|
103
|
-
* .filter(op => op.eq('status', 'ACTIVE'))
|
|
104
|
-
* .consistentRead()
|
|
105
|
-
* .execute();
|
|
106
|
-
*
|
|
107
|
-
* // Monitor security breaches
|
|
108
|
-
* const result = await builder
|
|
109
|
-
* .useIndex('primary-index')
|
|
110
|
-
* .consistentRead(isEmergencyMode)
|
|
111
|
-
* .execute();
|
|
112
|
-
* ```
|
|
113
|
-
*
|
|
114
|
-
* @param consistentRead - Whether to use consistent reads (defaults to true)
|
|
115
|
-
* @returns The builder instance for method chaining
|
|
116
|
-
*/
|
|
117
|
-
consistentRead(consistentRead?: boolean): this;
|
|
118
|
-
/**
|
|
119
|
-
* Adds a filter expression to refine the operation results.
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
* ```typescript
|
|
123
|
-
* // Find aggressive carnivores
|
|
124
|
-
* builder.filter(op =>
|
|
125
|
-
* op.and([
|
|
126
|
-
* op.eq('diet', 'CARNIVORE'),
|
|
127
|
-
* op.gt('aggressionLevel', 7),
|
|
128
|
-
* op.eq('status', 'ACTIVE')
|
|
129
|
-
* ])
|
|
130
|
-
* );
|
|
131
|
-
*
|
|
132
|
-
* // Search suitable breeding habitats
|
|
133
|
-
* builder.filter(op =>
|
|
134
|
-
* op.and([
|
|
135
|
-
* op.between('temperature', 25, 30),
|
|
136
|
-
* op.lt('currentOccupants', 3),
|
|
137
|
-
* op.eq('quarantineStatus', 'CLEAR')
|
|
138
|
-
* ])
|
|
139
|
-
* );
|
|
140
|
-
* ```
|
|
141
|
-
*
|
|
142
|
-
* @param condition - Either a Condition object or a callback function that builds the condition
|
|
143
|
-
* @returns The builder instance for method chaining
|
|
144
|
-
*/
|
|
145
|
-
filter(condition: Condition | ((op: ConditionOperator<T>) => Condition)): this;
|
|
146
|
-
private getConditionOperator;
|
|
147
|
-
/**
|
|
148
|
-
* Specifies which attributes to return in the results.
|
|
149
|
-
*
|
|
150
|
-
* @example
|
|
151
|
-
* ```typescript
|
|
152
|
-
* // Get basic dinosaur info
|
|
153
|
-
* builder.select([
|
|
154
|
-
* 'species',
|
|
155
|
-
* 'status',
|
|
156
|
-
* 'stats.health',
|
|
157
|
-
* 'stats.aggressionLevel'
|
|
158
|
-
* ]);
|
|
159
|
-
*
|
|
160
|
-
* // Monitor habitat conditions
|
|
161
|
-
* builder
|
|
162
|
-
* .select('securityStatus')
|
|
163
|
-
* .select([
|
|
164
|
-
* 'currentOccupants',
|
|
165
|
-
* 'temperature',
|
|
166
|
-
* 'lastInspectionDate'
|
|
167
|
-
* ]);
|
|
168
|
-
* ```
|
|
169
|
-
*
|
|
170
|
-
* @param fields - A single field name or an array of field names to return
|
|
171
|
-
* @returns The builder instance for method chaining
|
|
172
|
-
*/
|
|
173
|
-
select<K extends Path<T>>(fields: K | K[]): this;
|
|
174
|
-
/**
|
|
175
|
-
* Creates a paginator that handles DynamoDB pagination automatically.
|
|
176
|
-
* The paginator handles:
|
|
177
|
-
* - Tracking the last evaluated key
|
|
178
|
-
* - Managing page boundaries
|
|
179
|
-
* - Respecting overall query limits
|
|
180
|
-
*
|
|
181
|
-
* @example
|
|
182
|
-
* ```typescript
|
|
183
|
-
* // Create a paginator for dinosaur records with specific page size
|
|
184
|
-
* const paginator = builder
|
|
185
|
-
* .filter(op => op.eq('status', 'ACTIVE'))
|
|
186
|
-
* .paginate(10);
|
|
187
|
-
*
|
|
188
|
-
* // Create a paginator with automatic DynamoDB paging (no page size limit)
|
|
189
|
-
* const autoPaginator = builder
|
|
190
|
-
* .filter(op => op.eq('status', 'ACTIVE'))
|
|
191
|
-
* .paginate();
|
|
192
|
-
*
|
|
193
|
-
* // Process pages of dinosaur results
|
|
194
|
-
* while (paginator.hasNextPage()) {
|
|
195
|
-
* const page = await paginator.getNextPage();
|
|
196
|
-
* console.log(`Processing page ${page.page}, count: ${page.items.length}`);
|
|
197
|
-
* // Process dinosaur data
|
|
198
|
-
* }
|
|
199
|
-
* ```
|
|
200
|
-
*
|
|
201
|
-
* @param pageSize - The number of items to return per page. If not provided, DynamoDB will automatically determine page sizes.
|
|
202
|
-
* @returns A Paginator instance that manages the pagination state
|
|
203
|
-
* @see Paginator for more pagination control options
|
|
204
|
-
*/
|
|
205
|
-
paginate(pageSize?: number): Paginator<T, TConfig>;
|
|
206
|
-
/**
|
|
207
|
-
* Sets the starting point using a previous lastEvaluatedKey.
|
|
208
|
-
*
|
|
209
|
-
* Note: This method is typically used for manual pagination.
|
|
210
|
-
* For automatic pagination, use the paginate() method instead.
|
|
211
|
-
*
|
|
212
|
-
* @example
|
|
213
|
-
* ```typescript
|
|
214
|
-
* // First batch of dinosaurs
|
|
215
|
-
* const result1 = await builder
|
|
216
|
-
* .filter(op => op.eq('status', 'ACTIVE'))
|
|
217
|
-
* .limit(5)
|
|
218
|
-
* .execute();
|
|
219
|
-
*
|
|
220
|
-
* const lastKey = result1.getLastEvaluatedKey();
|
|
221
|
-
* if (lastKey) {
|
|
222
|
-
* // Continue listing dinosaurs
|
|
223
|
-
* const result2 = await builder
|
|
224
|
-
* .filter(op => op.eq('status', 'ACTIVE'))
|
|
225
|
-
* .startFrom(lastKey)
|
|
226
|
-
* .limit(5)
|
|
227
|
-
* .execute();
|
|
228
|
-
*
|
|
229
|
-
* const items = await result2.toArray();
|
|
230
|
-
* console.log('Additional dinosaurs:', items);
|
|
231
|
-
* }
|
|
232
|
-
* ```
|
|
233
|
-
*
|
|
234
|
-
* @param lastEvaluatedKey - The exclusive start key from a previous result
|
|
235
|
-
* @returns The builder instance for method chaining
|
|
236
|
-
*/
|
|
237
|
-
startFrom(lastEvaluatedKey: DynamoItem): this;
|
|
238
|
-
/**
|
|
239
|
-
* Creates a deep clone of this builder instance.
|
|
240
|
-
*
|
|
241
|
-
* This is particularly useful when:
|
|
242
|
-
* - Implementing pagination (used internally by paginate())
|
|
243
|
-
* - Creating operation templates
|
|
244
|
-
* - Running multiple variations of an operation
|
|
245
|
-
*
|
|
246
|
-
* @example
|
|
247
|
-
* ```typescript
|
|
248
|
-
* // Create base dinosaur query
|
|
249
|
-
* const baseBuilder = builder
|
|
250
|
-
* .useIndex('status-index')
|
|
251
|
-
* .select(['id', 'status', 'location']);
|
|
252
|
-
*
|
|
253
|
-
* // Check active dinosaurs
|
|
254
|
-
* const activeRaptors = baseBuilder.clone()
|
|
255
|
-
* .filter(op => op.eq('status', 'HUNTING'))
|
|
256
|
-
* .execute();
|
|
257
|
-
*
|
|
258
|
-
* // Check contained dinosaurs
|
|
259
|
-
* const containedRaptors = baseBuilder.clone()
|
|
260
|
-
* .filter(op => op.eq('status', 'CONTAINED'))
|
|
261
|
-
* .execute();
|
|
262
|
-
* ```
|
|
263
|
-
*
|
|
264
|
-
* @returns A new builder instance with the same configuration
|
|
265
|
-
*/
|
|
266
|
-
abstract clone(): FilterBuilderInterface<T, TConfig>;
|
|
267
|
-
/**
|
|
268
|
-
* Executes the operation against DynamoDB and returns a generator that behaves like an array.
|
|
269
|
-
* This method must be implemented by subclasses to handle
|
|
270
|
-
* their specific execution logic.
|
|
271
|
-
*/
|
|
272
|
-
abstract execute(): Promise<ResultIterator<T, TConfig>>;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Configuration options for DynamoDB query operations.
|
|
277
|
-
* Extends the base FilterOptions with query-specific options.
|
|
278
|
-
*/
|
|
279
|
-
interface QueryOptions extends FilterOptions {
|
|
280
|
-
/** Condition for the sort key in the table or index */
|
|
281
|
-
sortKeyCondition?: Condition;
|
|
282
|
-
/** Direction of sort key traversal (true for ascending, false for descending) */
|
|
283
|
-
scanIndexForward?: boolean;
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Function type for executing DynamoDB query operations.
|
|
287
|
-
* @typeParam T - The type of items being queried
|
|
288
|
-
*/
|
|
289
|
-
type QueryExecutor<T extends DynamoItem> = (keyCondition: Condition, options: QueryOptions) => Promise<{
|
|
290
|
-
items: T[];
|
|
291
|
-
lastEvaluatedKey?: Record<string, unknown>;
|
|
292
|
-
}>;
|
|
293
|
-
/**
|
|
294
|
-
* Builder for creating DynamoDB query operations.
|
|
295
|
-
*
|
|
296
|
-
* The builder supports:
|
|
297
|
-
* - Type-safe GSI selection
|
|
298
|
-
* - Complex filter conditions
|
|
299
|
-
* - Automatic pagination handling
|
|
300
|
-
* - Consistent reads
|
|
301
|
-
* - Forward and reverse sorting
|
|
302
|
-
*
|
|
303
|
-
* @example
|
|
304
|
-
* ```typescript
|
|
305
|
-
* // Simple query
|
|
306
|
-
* const result = await new QueryBuilder(executor, eq('userId', '123'))
|
|
307
|
-
* .execute();
|
|
308
|
-
*
|
|
309
|
-
* // Complex query with GSI and filtering
|
|
310
|
-
* const result = await new QueryBuilder(executor, eq('status', 'ACTIVE'))
|
|
311
|
-
* .useIndex('status-index')
|
|
312
|
-
* .filter(op => op.beginsWith('name', 'John'))
|
|
313
|
-
* .select(['id', 'name', 'email'])
|
|
314
|
-
* .sortDescending()
|
|
315
|
-
* .limit(10)
|
|
316
|
-
* .execute();
|
|
317
|
-
*
|
|
318
|
-
* // Query with pagination
|
|
319
|
-
* const paginator = new QueryBuilder(executor, eq('type', 'order'))
|
|
320
|
-
* .paginate(25);
|
|
321
|
-
*
|
|
322
|
-
* while (paginator.hasNextPage()) {
|
|
323
|
-
* const page = await paginator.getNextPage();
|
|
324
|
-
* // Process page.items
|
|
325
|
-
* }
|
|
326
|
-
* ```
|
|
327
|
-
*
|
|
328
|
-
* @typeParam T - The type of items being queried
|
|
329
|
-
* @typeParam TConfig - The table configuration type for type-safe GSI selection
|
|
330
|
-
*/
|
|
331
|
-
declare class QueryBuilder<T extends DynamoItem, TConfig extends TableConfig = TableConfig> extends FilterBuilder<T, TConfig> implements QueryBuilderInterface<T, TConfig> {
|
|
332
|
-
private readonly keyCondition;
|
|
333
|
-
protected options: QueryOptions;
|
|
334
|
-
protected readonly executor: QueryExecutor<T>;
|
|
335
|
-
constructor(executor: QueryExecutor<T>, keyCondition: Condition);
|
|
336
|
-
/**
|
|
337
|
-
* Sets the maximum number of items to return from the query.
|
|
338
|
-
*
|
|
339
|
-
* Note: This is the default behavior if no sort order is specified.
|
|
340
|
-
*
|
|
341
|
-
* @example
|
|
342
|
-
* ```typescript
|
|
343
|
-
* // Get orders in chronological order
|
|
344
|
-
* const result = await new QueryBuilder(executor, eq('userId', '123'))
|
|
345
|
-
* .sortAscending()
|
|
346
|
-
* .execute();
|
|
347
|
-
*
|
|
348
|
-
* // Get events from oldest to newest
|
|
349
|
-
* const result = await new QueryBuilder(executor, eq('entityId', 'order-123'))
|
|
350
|
-
* .useIndex('entity-timestamp-index')
|
|
351
|
-
* .sortAscending()
|
|
352
|
-
* .execute();
|
|
353
|
-
* ```
|
|
354
|
-
*
|
|
355
|
-
* @returns The builder instance for method chaining
|
|
356
|
-
*/
|
|
357
|
-
/**
|
|
358
|
-
* Sets the query to return items in ascending order by sort key.
|
|
359
|
-
*
|
|
360
|
-
* @example
|
|
361
|
-
* ```typescript
|
|
362
|
-
* // List dinosaurs by age
|
|
363
|
-
* const result = await new QueryBuilder(executor, eq('species', 'Velociraptor'))
|
|
364
|
-
* .useIndex('age-index')
|
|
365
|
-
* .sortAscending()
|
|
366
|
-
* .execute();
|
|
367
|
-
*
|
|
368
|
-
* // View incidents chronologically
|
|
369
|
-
* const result = await new QueryBuilder(executor, eq('type', 'SECURITY_BREACH'))
|
|
370
|
-
* .useIndex('date-index')
|
|
371
|
-
* .sortAscending()
|
|
372
|
-
* .execute();
|
|
373
|
-
* ```
|
|
374
|
-
*
|
|
375
|
-
* @returns The builder instance for method chaining
|
|
376
|
-
*/
|
|
377
|
-
sortAscending(): this;
|
|
378
|
-
/**
|
|
379
|
-
* Sets the query to return items in descending order by sort key.
|
|
380
|
-
*
|
|
381
|
-
* @example
|
|
382
|
-
* ```typescript
|
|
383
|
-
* // Get most recent security incidents
|
|
384
|
-
* const result = await new QueryBuilder(executor, eq('type', 'SECURITY_BREACH'))
|
|
385
|
-
* .useIndex('date-index')
|
|
386
|
-
* .sortDescending()
|
|
387
|
-
* .limit(10)
|
|
388
|
-
* .execute();
|
|
389
|
-
*
|
|
390
|
-
* // Check latest dinosaur activities
|
|
391
|
-
* const result = await new QueryBuilder(executor, eq('species', 'Velociraptor'))
|
|
392
|
-
* .useIndex('activity-time-index')
|
|
393
|
-
* .filter(op => op.eq('status', 'ACTIVE'))
|
|
394
|
-
* .sortDescending()
|
|
395
|
-
* .execute();
|
|
396
|
-
* ```
|
|
397
|
-
*
|
|
398
|
-
* @returns The builder instance for method chaining
|
|
399
|
-
*/
|
|
400
|
-
sortDescending(): this;
|
|
401
|
-
/**
|
|
402
|
-
* Creates a deep clone of this QueryBuilder instance.
|
|
403
|
-
*
|
|
404
|
-
* This is particularly useful when:
|
|
405
|
-
* - Implementing pagination (used internally by paginate())
|
|
406
|
-
* - Creating query templates
|
|
407
|
-
* - Running multiple variations of a query
|
|
408
|
-
*
|
|
409
|
-
* @example
|
|
410
|
-
* ```typescript
|
|
411
|
-
* // Create base dinosaur query
|
|
412
|
-
* const baseQuery = new QueryBuilder(executor, eq('species', 'Velociraptor'))
|
|
413
|
-
* .useIndex('status-index')
|
|
414
|
-
* .select(['id', 'status', 'location']);
|
|
415
|
-
*
|
|
416
|
-
* // Check active dinosaurs
|
|
417
|
-
* const activeRaptors = baseQuery.clone()
|
|
418
|
-
* .filter(op => op.eq('status', 'HUNTING'))
|
|
419
|
-
* .execute();
|
|
420
|
-
*
|
|
421
|
-
* // Check contained dinosaurs
|
|
422
|
-
* const containedRaptors = baseQuery.clone()
|
|
423
|
-
* .filter(op => op.eq('status', 'CONTAINED'))
|
|
424
|
-
* .execute();
|
|
425
|
-
*
|
|
426
|
-
* // Check sedated dinosaurs
|
|
427
|
-
* const sedatedRaptors = baseQuery.clone()
|
|
428
|
-
* .filter(op => op.eq('status', 'SEDATED'))
|
|
429
|
-
* .execute();
|
|
430
|
-
* ```
|
|
431
|
-
*
|
|
432
|
-
* @returns A new QueryBuilder instance with the same configuration
|
|
433
|
-
*/
|
|
434
|
-
clone(): QueryBuilder<T, TConfig>;
|
|
435
|
-
private deepCloneFilter;
|
|
436
|
-
/**
|
|
437
|
-
* Executes the query against DynamoDB and returns a generator that behaves like an array.
|
|
438
|
-
*
|
|
439
|
-
* The generator automatically handles pagination and provides array-like methods
|
|
440
|
-
* for processing results efficiently without loading everything into memory at once.
|
|
441
|
-
*
|
|
442
|
-
* @example
|
|
443
|
-
* ```typescript
|
|
444
|
-
* try {
|
|
445
|
-
* // Find active carnivores with automatic pagination
|
|
446
|
-
* const results = await new QueryBuilder(executor, eq('habitatId', 'PADDOCK-A'))
|
|
447
|
-
* .useIndex('species-status-index')
|
|
448
|
-
* .filter(op =>
|
|
449
|
-
* op.and([
|
|
450
|
-
* op.eq('diet', 'CARNIVORE'),
|
|
451
|
-
* op.eq('status', 'ACTIVE'),
|
|
452
|
-
* op.gt('aggressionLevel', 7)
|
|
453
|
-
* ])
|
|
454
|
-
* )
|
|
455
|
-
* .sortDescending()
|
|
456
|
-
* .execute();
|
|
457
|
-
*
|
|
458
|
-
* // Use like an array with automatic pagination
|
|
459
|
-
* for await (const dinosaur of results) {
|
|
460
|
-
* console.log(`Processing ${dinosaur.name}`);
|
|
461
|
-
* }
|
|
462
|
-
*
|
|
463
|
-
* // Or convert to array and use array methods
|
|
464
|
-
* const allItems = await results.toArray();
|
|
465
|
-
* const dangerousOnes = allItems.filter(dino => dino.aggressionLevel > 9);
|
|
466
|
-
* const totalCount = allItems.length;
|
|
467
|
-
* } catch (error) {
|
|
468
|
-
* console.error('Security scan failed:', error);
|
|
469
|
-
* }
|
|
470
|
-
* ```
|
|
471
|
-
*
|
|
472
|
-
* @returns A promise that resolves to a ResultGenerator that behaves like an array
|
|
473
|
-
*/
|
|
474
|
-
execute(): Promise<ResultIterator<T, TConfig>>;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
export { FilterBuilder as F, QueryBuilder as Q, type QueryOptions as a, type FilterOptions as b };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"standard-schema.cjs"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"standard-schema.js"}
|