diff --git a/packages/nodes-base/nodes/Aws/DynamoDB/AwsDynamoDB.node.ts b/packages/nodes-base/nodes/Aws/DynamoDB/AwsDynamoDB.node.ts index 39d170ad4c..a81e041092 100644 --- a/packages/nodes-base/nodes/Aws/DynamoDB/AwsDynamoDB.node.ts +++ b/packages/nodes-base/nodes/Aws/DynamoDB/AwsDynamoDB.node.ts @@ -301,26 +301,34 @@ export class AwsDynamoDB implements INodeType { const simple = this.getNodeParameter('simple', 0, false) as boolean; const select = this.getNodeParameter('select', 0) as string; const returnAll = this.getNodeParameter('returnAll', 0) as boolean; + const scan = this.getNodeParameter('scan', 0) as boolean; const eanUi = this.getNodeParameter('additionalFields.eanUi.eanValues', i, []) as IAttributeNameUi[]; const body: IRequestBody = { TableName: this.getNodeParameter('tableName', i) as string, - KeyConditionExpression: this.getNodeParameter('keyConditionExpression', i) as string, ExpressionAttributeValues: adjustExpressionAttributeValues(eavUi), }; + if (scan === true) { + body['FilterExpression'] = this.getNodeParameter('filterExpression', i) as string; + } else { + body['KeyConditionExpression'] = this.getNodeParameter('KeyConditionExpression', i) as string; + } + const { indexName, projectionExpression, + filterExpression, } = this.getNodeParameter('options', i) as { indexName: string; projectionExpression: string; + filterExpression: string; }; const expressionAttributeName = adjustExpressionAttributeName(eanUi); if (Object.keys(expressionAttributeName).length) { - body.expressionAttributeNames = expressionAttributeName; + body.ExpressionAttributeNames = expressionAttributeName; } if (indexName) { @@ -331,13 +339,17 @@ export class AwsDynamoDB implements INodeType { body.ProjectionExpression = projectionExpression; } + if (filterExpression) { + body.FilterExpression = filterExpression; + } + if (select) { body.Select = select; } const headers = { 'Content-Type': 'application/json', - 'X-Amz-Target': 'DynamoDB_20120810.Query', + 'X-Amz-Target': (scan) ? 'DynamoDB_20120810.Scan' : 'DynamoDB_20120810.Query', }; if (returnAll === true && select !== 'COUNT') { @@ -352,6 +364,7 @@ export class AwsDynamoDB implements INodeType { if (simple === true) { responseData = responseData.map(simplify); } + } Array.isArray(responseData) diff --git a/packages/nodes-base/nodes/Aws/DynamoDB/ItemDescription.ts b/packages/nodes-base/nodes/Aws/DynamoDB/ItemDescription.ts index 47a7a02599..e89d5ef3d6 100644 --- a/packages/nodes-base/nodes/Aws/DynamoDB/ItemDescription.ts +++ b/packages/nodes-base/nodes/Aws/DynamoDB/ItemDescription.ts @@ -673,6 +673,38 @@ export const itemFields = [ // ---------------------------------- // Get All // ---------------------------------- + { + displayName: 'Scan', + name: 'scan', + type: 'boolean', + displayOptions: { + show: { + resource: [ + 'item', + ], + operation: [ + 'getAll', + ], + }, + }, + default: false, + description: 'Whether to do an scan or query. Check differences', + }, + { + displayName: 'Filter Expression', + name: 'filterExpression', + type: 'string', + required: true, + displayOptions: { + show: { + scan: [ + true, + ], + }, + }, + default: '', + description: 'A filter expression determines which items within the Scan results should be returned to you. All of the other results are discarded.', + }, { displayName: 'Key Condition Expression', name: 'keyConditionExpression', @@ -689,6 +721,9 @@ export const itemFields = [ operation: [ 'getAll', ], + scan: [ + false, + ], }, }, }, @@ -881,6 +916,13 @@ export const itemFields = [ displayName: 'Filter Expression', name: 'filterExpression', type: 'string', + displayOptions: { + show: { + '/scan': [ + false, + ], + }, + }, default: '', description: 'Text that contains conditions that DynamoDB applies after the Query operation,
but before the data is returned. Items that do not satisfy the FilterExpression criteria
are not returned', },