@resistdesign/voltra 3.0.0-alpha.52 → 3.0.0-alpha.53
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.
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @packageDocumentation
|
|
3
3
|
*
|
|
4
|
-
* DynamoDB-backed data item driver for TypeInfo ORM. Supports CRUD and
|
|
5
|
-
*
|
|
4
|
+
* DynamoDB-backed data item driver for TypeInfo ORM. Supports CRUD and list
|
|
5
|
+
* operations using scans by default, or GSI-backed queries when a sort field is
|
|
6
|
+
* supplied.
|
|
6
7
|
*/
|
|
7
8
|
import { DataItemDBDriver, DataItemDBDriverConfig, SupportedDataItemDBDriverEntry } from "./common/Types";
|
|
8
9
|
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
|
package/api/index.js
CHANGED
|
@@ -5964,6 +5964,8 @@ var DynamoDBDataItemDBDriver = class {
|
|
|
5964
5964
|
ExpressionAttributeNames,
|
|
5965
5965
|
ExpressionAttributeValues
|
|
5966
5966
|
} = createFilterExpression(fieldCriteria, logicalOperator);
|
|
5967
|
+
const primarySortField = sortFields?.[0];
|
|
5968
|
+
const indexName = primarySortField?.field;
|
|
5967
5969
|
const params = {
|
|
5968
5970
|
TableName: tableName,
|
|
5969
5971
|
Select: selectedFields && selectedFields.length > 0 ? "SPECIFIC_ATTRIBUTES" : "ALL_ATTRIBUTES",
|
|
@@ -5998,14 +6000,24 @@ var DynamoDBDataItemDBDriver = class {
|
|
|
5998
6000
|
};
|
|
5999
6001
|
}
|
|
6000
6002
|
}
|
|
6001
|
-
const
|
|
6003
|
+
const commandInput = indexName ? {
|
|
6004
|
+
...params,
|
|
6005
|
+
IndexName: indexName,
|
|
6006
|
+
KeyConditionExpression: FilterExpression,
|
|
6007
|
+
ExclusiveStartKey: structuredCursor,
|
|
6008
|
+
Limit: itemsPerPage,
|
|
6009
|
+
ScanIndexForward: !primarySortField?.reverse
|
|
6010
|
+
} : {
|
|
6002
6011
|
...params,
|
|
6003
6012
|
ExclusiveStartKey: structuredCursor,
|
|
6004
6013
|
Limit: itemsPerPage
|
|
6005
|
-
}
|
|
6006
|
-
const
|
|
6014
|
+
};
|
|
6015
|
+
const command = indexName ? new QueryCommand(commandInput) : new ScanCommand(commandInput);
|
|
6016
|
+
const { Items = [], LastEvaluatedKey } = await this.dynamoDBClient.send(
|
|
6017
|
+
command
|
|
6018
|
+
);
|
|
6007
6019
|
const unmarshalledItems = Items.map((item) => unmarshall(item));
|
|
6008
|
-
const sortedItems = getSortedItems(sortFields, unmarshalledItems);
|
|
6020
|
+
const sortedItems = indexName ? unmarshalledItems : getSortedItems(sortFields, unmarshalledItems);
|
|
6009
6021
|
return {
|
|
6010
6022
|
items: sortedItems,
|
|
6011
6023
|
cursor: LastEvaluatedKey ? JSON.stringify(unmarshall(LastEvaluatedKey)) : void 0
|