ag-common 0.0.354 → 0.0.355
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.
|
@@ -21,7 +21,15 @@ export declare const batchDelete: ({ tableName, breakOnError, pkName, keys, rang
|
|
|
21
21
|
} | {
|
|
22
22
|
error?: undefined;
|
|
23
23
|
}>;
|
|
24
|
-
export declare const scan: <T>(tableName: string
|
|
24
|
+
export declare const scan: <T>(tableName: string, opt?: {
|
|
25
|
+
filter?: {
|
|
26
|
+
filterExpression: string;
|
|
27
|
+
attrNames: Record<string, string>;
|
|
28
|
+
attrValues: Record<string, string>;
|
|
29
|
+
};
|
|
30
|
+
/** ProjectionExpression. will csv values */
|
|
31
|
+
requiredAttributeList?: string[];
|
|
32
|
+
}) => Promise<T[]>;
|
|
25
33
|
export declare const getItemDynamo: <T>({ tableName, pkName, pkValue, }: {
|
|
26
34
|
pkName: string;
|
|
27
35
|
pkValue: string;
|
|
@@ -144,15 +144,25 @@ const batchDelete = ({ tableName, breakOnError = true, pkName, keys, rangeName,
|
|
|
144
144
|
return {};
|
|
145
145
|
});
|
|
146
146
|
exports.batchDelete = batchDelete;
|
|
147
|
-
const scan = (tableName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
147
|
+
const scan = (tableName, opt) => __awaiter(void 0, void 0, void 0, function* () {
|
|
148
148
|
const Items = [];
|
|
149
149
|
let ExclusiveStartKey;
|
|
150
150
|
do {
|
|
151
|
+
let params = {
|
|
152
|
+
TableName: tableName,
|
|
153
|
+
ExclusiveStartKey,
|
|
154
|
+
};
|
|
155
|
+
if (opt === null || opt === void 0 ? void 0 : opt.filter) {
|
|
156
|
+
params.FilterExpression = opt.filter.filterExpression;
|
|
157
|
+
params.ExpressionAttributeNames = opt.filter.attrNames;
|
|
158
|
+
params.ExpressionAttributeValues = opt.filter.attrValues;
|
|
159
|
+
}
|
|
160
|
+
if (opt === null || opt === void 0 ? void 0 : opt.requiredAttributeList) {
|
|
161
|
+
params.ProjectionExpression = opt.requiredAttributeList.join(', ');
|
|
162
|
+
}
|
|
151
163
|
const { Items: newitems, LastEvaluatedKey, $response,
|
|
152
164
|
// eslint-disable-next-line no-await-in-loop
|
|
153
|
-
} = yield exports.dynamoDb
|
|
154
|
-
.scan({ TableName: tableName, ExclusiveStartKey })
|
|
155
|
-
.promise();
|
|
165
|
+
} = yield exports.dynamoDb.scan(params).promise();
|
|
156
166
|
ExclusiveStartKey = LastEvaluatedKey;
|
|
157
167
|
if ($response.error && $response.error.statusCode) {
|
|
158
168
|
throw new Error($response.error.message);
|