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
package/dist/table.d.cts
CHANGED
|
@@ -1,13 +1,164 @@
|
|
|
1
|
-
import './
|
|
2
|
-
import './
|
|
3
|
-
import './
|
|
4
|
-
import './builders/put-builder.cjs';
|
|
5
|
-
import './query-builder-D3URwK9k.cjs';
|
|
6
|
-
export { T as Table } from './table-ClST8nkR.cjs';
|
|
7
|
-
import './builders/transaction-builder.cjs';
|
|
8
|
-
import './builders/update-builder.cjs';
|
|
9
|
-
import './conditions-CcZL0sR2.cjs';
|
|
10
|
-
import './types.cjs';
|
|
11
|
-
import './builder-types-BTVhQSHI.cjs';
|
|
1
|
+
import { P as PutBuilder, G as GetBuilder, Q as QueryBuilder, S as ScanBuilder, D as DeleteBuilder, U as UpdateBuilder, T as TransactionBuilder, B as BatchBuilder, f as TransactionOptions, C as ConditionCheckBuilder, h as BatchWriteOperation } from './index-DlN8G9hd.cjs';
|
|
2
|
+
import { c as PrimaryKeyWithoutExpression, P as PrimaryKey } from './conditions-CcZL0sR2.cjs';
|
|
3
|
+
import { TableConfig, Index, DynamoItem } from './types.cjs';
|
|
12
4
|
import '@aws-sdk/lib-dynamodb';
|
|
13
|
-
|
|
5
|
+
|
|
6
|
+
declare class Table<TConfig extends TableConfig = TableConfig> {
|
|
7
|
+
private readonly dynamoClient;
|
|
8
|
+
readonly tableName: string;
|
|
9
|
+
/**
|
|
10
|
+
* The column name of the partitionKey for the Table
|
|
11
|
+
*/
|
|
12
|
+
readonly partitionKey: string;
|
|
13
|
+
/**
|
|
14
|
+
* The column name of the sortKey for the Table
|
|
15
|
+
*/
|
|
16
|
+
readonly sortKey?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The Global Secondary Indexes that are configured on this table
|
|
19
|
+
*/
|
|
20
|
+
readonly gsis: Record<string, Index>;
|
|
21
|
+
constructor(config: TConfig);
|
|
22
|
+
protected createKeyForPrimaryIndex(keyCondition: PrimaryKeyWithoutExpression): Record<string, unknown>;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new item in the table, it will fail if the item already exists.
|
|
25
|
+
*
|
|
26
|
+
* By default, this method returns the input values passed to the create operation
|
|
27
|
+
* upon successful creation.
|
|
28
|
+
*
|
|
29
|
+
* You can customise the return behaviour by chaining the `.returnValues()` method:
|
|
30
|
+
*
|
|
31
|
+
* @param item The item to create
|
|
32
|
+
* @returns A PutBuilder instance for chaining additional conditions and executing the create operation
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* // Create with default behavior (returns input values)
|
|
37
|
+
* const result = await table.create({
|
|
38
|
+
* id: 'user-123',
|
|
39
|
+
* name: 'John Doe',
|
|
40
|
+
* email: 'john@example.com'
|
|
41
|
+
* }).execute();
|
|
42
|
+
* console.log(result); // Returns the input object
|
|
43
|
+
*
|
|
44
|
+
* // Create with no return value for better performance
|
|
45
|
+
* await table.create(userData).returnValues('NONE').execute();
|
|
46
|
+
*
|
|
47
|
+
* // Create and get fresh data from dynamodb using a strongly consistent read
|
|
48
|
+
* const freshData = await table.create(userData).returnValues('CONSISTENT').execute();
|
|
49
|
+
*
|
|
50
|
+
* // Create and get previous values (if the item was overwritten)
|
|
51
|
+
* const oldData = await table.create(userData).returnValues('ALL_OLD').execute();
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
create<T extends DynamoItem>(item: T): PutBuilder<T>;
|
|
55
|
+
get<T extends DynamoItem>(keyCondition: PrimaryKeyWithoutExpression): GetBuilder<T>;
|
|
56
|
+
/**
|
|
57
|
+
* Updates an item in the table
|
|
58
|
+
*
|
|
59
|
+
* @param item The item to update
|
|
60
|
+
* @returns A PutBuilder instance for chaining conditions and executing the put operation
|
|
61
|
+
*/
|
|
62
|
+
put<T extends DynamoItem>(item: T): PutBuilder<T>;
|
|
63
|
+
/**
|
|
64
|
+
* Creates a query builder for complex queries
|
|
65
|
+
* If useIndex is called on the returned QueryBuilder, it will use the GSI configuration
|
|
66
|
+
*/
|
|
67
|
+
query<T extends DynamoItem>(keyCondition: PrimaryKey): QueryBuilder<T, TConfig>;
|
|
68
|
+
/**
|
|
69
|
+
* Creates a scan builder for scanning the entire table
|
|
70
|
+
* Use this when you need to:
|
|
71
|
+
* - Process all items in a table
|
|
72
|
+
* - Apply filters to a large dataset
|
|
73
|
+
* - Use a GSI for scanning
|
|
74
|
+
*
|
|
75
|
+
* @returns A ScanBuilder instance for chaining operations
|
|
76
|
+
*/
|
|
77
|
+
scan<T extends DynamoItem>(): ScanBuilder<T, TConfig>;
|
|
78
|
+
delete(keyCondition: PrimaryKeyWithoutExpression): DeleteBuilder;
|
|
79
|
+
/**
|
|
80
|
+
* Updates an item in the table
|
|
81
|
+
*
|
|
82
|
+
* @param keyCondition The primary key of the item to update
|
|
83
|
+
* @returns An UpdateBuilder instance for chaining update operations and conditions
|
|
84
|
+
*/
|
|
85
|
+
update<T extends DynamoItem>(keyCondition: PrimaryKeyWithoutExpression): UpdateBuilder<T>;
|
|
86
|
+
/**
|
|
87
|
+
* Creates a transaction builder for performing multiple operations atomically
|
|
88
|
+
*/
|
|
89
|
+
transactionBuilder(): TransactionBuilder;
|
|
90
|
+
/**
|
|
91
|
+
* Creates a batch builder for performing multiple operations efficiently with optional type inference
|
|
92
|
+
*
|
|
93
|
+
* @example Basic Usage
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const batch = table.batchBuilder();
|
|
96
|
+
*
|
|
97
|
+
* // Add operations
|
|
98
|
+
* userRepo.create(newUser).withBatch(batch);
|
|
99
|
+
* orderRepo.get({ id: 'order-1' }).withBatch(batch);
|
|
100
|
+
*
|
|
101
|
+
* // Execute operations
|
|
102
|
+
* const result = await batch.execute();
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @example Typed Usage
|
|
106
|
+
* ```typescript
|
|
107
|
+
* // Define entity types for the batch
|
|
108
|
+
* const batch = table.batchBuilder<{
|
|
109
|
+
* User: UserEntity;
|
|
110
|
+
* Order: OrderEntity;
|
|
111
|
+
* Product: ProductEntity;
|
|
112
|
+
* }>();
|
|
113
|
+
*
|
|
114
|
+
* // Add operations with type information
|
|
115
|
+
* userRepo.create(newUser).withBatch(batch, 'User');
|
|
116
|
+
* orderRepo.get({ id: 'order-1' }).withBatch(batch, 'Order');
|
|
117
|
+
* productRepo.delete({ id: 'old-product' }).withBatch(batch, 'Product');
|
|
118
|
+
*
|
|
119
|
+
* // Execute and get typed results
|
|
120
|
+
* const result = await batch.execute();
|
|
121
|
+
* const users: UserEntity[] = result.reads.itemsByType.User;
|
|
122
|
+
* const orders: OrderEntity[] = result.reads.itemsByType.Order;
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
batchBuilder<TEntities extends Record<string, DynamoItem> = Record<string, DynamoItem>>(): BatchBuilder<TEntities>;
|
|
126
|
+
/**
|
|
127
|
+
* Executes a transaction using a callback function
|
|
128
|
+
*
|
|
129
|
+
* @param callback A function that receives a transaction context and performs operations on it
|
|
130
|
+
* @param options Optional transaction options
|
|
131
|
+
* @returns A promise that resolves when the transaction is complete
|
|
132
|
+
*/
|
|
133
|
+
transaction(callback: (tx: TransactionBuilder) => Promise<void> | void, options?: TransactionOptions): Promise<void>;
|
|
134
|
+
/**
|
|
135
|
+
* Creates a condition check operation for use in transactions
|
|
136
|
+
*
|
|
137
|
+
* This is useful for when you require a transaction to succeed only when a specific condition is met on a
|
|
138
|
+
* a record within the database that you are not directly updating.
|
|
139
|
+
*
|
|
140
|
+
* For example, you are updating a record and you want to ensure that another record exists and/or has a specific value before proceeding.
|
|
141
|
+
*/
|
|
142
|
+
conditionCheck(keyCondition: PrimaryKeyWithoutExpression): ConditionCheckBuilder;
|
|
143
|
+
/**
|
|
144
|
+
* Performs a batch get operation to retrieve multiple items at once
|
|
145
|
+
*
|
|
146
|
+
* @param keys Array of primary keys to retrieve
|
|
147
|
+
* @returns A promise that resolves to the retrieved items
|
|
148
|
+
*/
|
|
149
|
+
batchGet<T extends DynamoItem>(keys: Array<PrimaryKeyWithoutExpression>): Promise<{
|
|
150
|
+
items: T[];
|
|
151
|
+
unprocessedKeys: PrimaryKeyWithoutExpression[];
|
|
152
|
+
}>;
|
|
153
|
+
/**
|
|
154
|
+
* Performs a batch write operation to put or delete multiple items at once
|
|
155
|
+
*
|
|
156
|
+
* @param operations Array of put or delete operations
|
|
157
|
+
* @returns A promise that resolves to any unprocessed operations
|
|
158
|
+
*/
|
|
159
|
+
batchWrite<T extends DynamoItem>(operations: Array<BatchWriteOperation<T>>): Promise<{
|
|
160
|
+
unprocessedItems: Array<BatchWriteOperation<T>>;
|
|
161
|
+
}>;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export { Table };
|
package/dist/table.d.ts
CHANGED
|
@@ -1,13 +1,164 @@
|
|
|
1
|
-
import './
|
|
2
|
-
import './
|
|
3
|
-
import './
|
|
4
|
-
import './builders/put-builder.js';
|
|
5
|
-
import './query-builder-cfEkU0_w.js';
|
|
6
|
-
export { T as Table } from './table-vE3cGoDy.js';
|
|
7
|
-
import './builders/transaction-builder.js';
|
|
8
|
-
import './builders/update-builder.js';
|
|
9
|
-
import './conditions-D_w7vVYG.js';
|
|
10
|
-
import './types.js';
|
|
11
|
-
import './builder-types-CzuLR4Th.js';
|
|
1
|
+
import { P as PutBuilder, G as GetBuilder, Q as QueryBuilder, S as ScanBuilder, D as DeleteBuilder, U as UpdateBuilder, T as TransactionBuilder, B as BatchBuilder, f as TransactionOptions, C as ConditionCheckBuilder, h as BatchWriteOperation } from './index-2cbm07Bi.js';
|
|
2
|
+
import { c as PrimaryKeyWithoutExpression, P as PrimaryKey } from './conditions-D_w7vVYG.js';
|
|
3
|
+
import { TableConfig, Index, DynamoItem } from './types.js';
|
|
12
4
|
import '@aws-sdk/lib-dynamodb';
|
|
13
|
-
|
|
5
|
+
|
|
6
|
+
declare class Table<TConfig extends TableConfig = TableConfig> {
|
|
7
|
+
private readonly dynamoClient;
|
|
8
|
+
readonly tableName: string;
|
|
9
|
+
/**
|
|
10
|
+
* The column name of the partitionKey for the Table
|
|
11
|
+
*/
|
|
12
|
+
readonly partitionKey: string;
|
|
13
|
+
/**
|
|
14
|
+
* The column name of the sortKey for the Table
|
|
15
|
+
*/
|
|
16
|
+
readonly sortKey?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The Global Secondary Indexes that are configured on this table
|
|
19
|
+
*/
|
|
20
|
+
readonly gsis: Record<string, Index>;
|
|
21
|
+
constructor(config: TConfig);
|
|
22
|
+
protected createKeyForPrimaryIndex(keyCondition: PrimaryKeyWithoutExpression): Record<string, unknown>;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new item in the table, it will fail if the item already exists.
|
|
25
|
+
*
|
|
26
|
+
* By default, this method returns the input values passed to the create operation
|
|
27
|
+
* upon successful creation.
|
|
28
|
+
*
|
|
29
|
+
* You can customise the return behaviour by chaining the `.returnValues()` method:
|
|
30
|
+
*
|
|
31
|
+
* @param item The item to create
|
|
32
|
+
* @returns A PutBuilder instance for chaining additional conditions and executing the create operation
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* // Create with default behavior (returns input values)
|
|
37
|
+
* const result = await table.create({
|
|
38
|
+
* id: 'user-123',
|
|
39
|
+
* name: 'John Doe',
|
|
40
|
+
* email: 'john@example.com'
|
|
41
|
+
* }).execute();
|
|
42
|
+
* console.log(result); // Returns the input object
|
|
43
|
+
*
|
|
44
|
+
* // Create with no return value for better performance
|
|
45
|
+
* await table.create(userData).returnValues('NONE').execute();
|
|
46
|
+
*
|
|
47
|
+
* // Create and get fresh data from dynamodb using a strongly consistent read
|
|
48
|
+
* const freshData = await table.create(userData).returnValues('CONSISTENT').execute();
|
|
49
|
+
*
|
|
50
|
+
* // Create and get previous values (if the item was overwritten)
|
|
51
|
+
* const oldData = await table.create(userData).returnValues('ALL_OLD').execute();
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
create<T extends DynamoItem>(item: T): PutBuilder<T>;
|
|
55
|
+
get<T extends DynamoItem>(keyCondition: PrimaryKeyWithoutExpression): GetBuilder<T>;
|
|
56
|
+
/**
|
|
57
|
+
* Updates an item in the table
|
|
58
|
+
*
|
|
59
|
+
* @param item The item to update
|
|
60
|
+
* @returns A PutBuilder instance for chaining conditions and executing the put operation
|
|
61
|
+
*/
|
|
62
|
+
put<T extends DynamoItem>(item: T): PutBuilder<T>;
|
|
63
|
+
/**
|
|
64
|
+
* Creates a query builder for complex queries
|
|
65
|
+
* If useIndex is called on the returned QueryBuilder, it will use the GSI configuration
|
|
66
|
+
*/
|
|
67
|
+
query<T extends DynamoItem>(keyCondition: PrimaryKey): QueryBuilder<T, TConfig>;
|
|
68
|
+
/**
|
|
69
|
+
* Creates a scan builder for scanning the entire table
|
|
70
|
+
* Use this when you need to:
|
|
71
|
+
* - Process all items in a table
|
|
72
|
+
* - Apply filters to a large dataset
|
|
73
|
+
* - Use a GSI for scanning
|
|
74
|
+
*
|
|
75
|
+
* @returns A ScanBuilder instance for chaining operations
|
|
76
|
+
*/
|
|
77
|
+
scan<T extends DynamoItem>(): ScanBuilder<T, TConfig>;
|
|
78
|
+
delete(keyCondition: PrimaryKeyWithoutExpression): DeleteBuilder;
|
|
79
|
+
/**
|
|
80
|
+
* Updates an item in the table
|
|
81
|
+
*
|
|
82
|
+
* @param keyCondition The primary key of the item to update
|
|
83
|
+
* @returns An UpdateBuilder instance for chaining update operations and conditions
|
|
84
|
+
*/
|
|
85
|
+
update<T extends DynamoItem>(keyCondition: PrimaryKeyWithoutExpression): UpdateBuilder<T>;
|
|
86
|
+
/**
|
|
87
|
+
* Creates a transaction builder for performing multiple operations atomically
|
|
88
|
+
*/
|
|
89
|
+
transactionBuilder(): TransactionBuilder;
|
|
90
|
+
/**
|
|
91
|
+
* Creates a batch builder for performing multiple operations efficiently with optional type inference
|
|
92
|
+
*
|
|
93
|
+
* @example Basic Usage
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const batch = table.batchBuilder();
|
|
96
|
+
*
|
|
97
|
+
* // Add operations
|
|
98
|
+
* userRepo.create(newUser).withBatch(batch);
|
|
99
|
+
* orderRepo.get({ id: 'order-1' }).withBatch(batch);
|
|
100
|
+
*
|
|
101
|
+
* // Execute operations
|
|
102
|
+
* const result = await batch.execute();
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @example Typed Usage
|
|
106
|
+
* ```typescript
|
|
107
|
+
* // Define entity types for the batch
|
|
108
|
+
* const batch = table.batchBuilder<{
|
|
109
|
+
* User: UserEntity;
|
|
110
|
+
* Order: OrderEntity;
|
|
111
|
+
* Product: ProductEntity;
|
|
112
|
+
* }>();
|
|
113
|
+
*
|
|
114
|
+
* // Add operations with type information
|
|
115
|
+
* userRepo.create(newUser).withBatch(batch, 'User');
|
|
116
|
+
* orderRepo.get({ id: 'order-1' }).withBatch(batch, 'Order');
|
|
117
|
+
* productRepo.delete({ id: 'old-product' }).withBatch(batch, 'Product');
|
|
118
|
+
*
|
|
119
|
+
* // Execute and get typed results
|
|
120
|
+
* const result = await batch.execute();
|
|
121
|
+
* const users: UserEntity[] = result.reads.itemsByType.User;
|
|
122
|
+
* const orders: OrderEntity[] = result.reads.itemsByType.Order;
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
batchBuilder<TEntities extends Record<string, DynamoItem> = Record<string, DynamoItem>>(): BatchBuilder<TEntities>;
|
|
126
|
+
/**
|
|
127
|
+
* Executes a transaction using a callback function
|
|
128
|
+
*
|
|
129
|
+
* @param callback A function that receives a transaction context and performs operations on it
|
|
130
|
+
* @param options Optional transaction options
|
|
131
|
+
* @returns A promise that resolves when the transaction is complete
|
|
132
|
+
*/
|
|
133
|
+
transaction(callback: (tx: TransactionBuilder) => Promise<void> | void, options?: TransactionOptions): Promise<void>;
|
|
134
|
+
/**
|
|
135
|
+
* Creates a condition check operation for use in transactions
|
|
136
|
+
*
|
|
137
|
+
* This is useful for when you require a transaction to succeed only when a specific condition is met on a
|
|
138
|
+
* a record within the database that you are not directly updating.
|
|
139
|
+
*
|
|
140
|
+
* For example, you are updating a record and you want to ensure that another record exists and/or has a specific value before proceeding.
|
|
141
|
+
*/
|
|
142
|
+
conditionCheck(keyCondition: PrimaryKeyWithoutExpression): ConditionCheckBuilder;
|
|
143
|
+
/**
|
|
144
|
+
* Performs a batch get operation to retrieve multiple items at once
|
|
145
|
+
*
|
|
146
|
+
* @param keys Array of primary keys to retrieve
|
|
147
|
+
* @returns A promise that resolves to the retrieved items
|
|
148
|
+
*/
|
|
149
|
+
batchGet<T extends DynamoItem>(keys: Array<PrimaryKeyWithoutExpression>): Promise<{
|
|
150
|
+
items: T[];
|
|
151
|
+
unprocessedKeys: PrimaryKeyWithoutExpression[];
|
|
152
|
+
}>;
|
|
153
|
+
/**
|
|
154
|
+
* Performs a batch write operation to put or delete multiple items at once
|
|
155
|
+
*
|
|
156
|
+
* @param operations Array of put or delete operations
|
|
157
|
+
* @returns A promise that resolves to any unprocessed operations
|
|
158
|
+
*/
|
|
159
|
+
batchWrite<T extends DynamoItem>(operations: Array<BatchWriteOperation<T>>): Promise<{
|
|
160
|
+
unprocessedItems: Array<BatchWriteOperation<T>>;
|
|
161
|
+
}>;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export { Table };
|