mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 12:57:29 -08:00
✨ Add scan option to item:getAll (DynamoDB) (#2085)
* aws dynamodb: fixes using FilterExpression on Query * aws dynamodb: add Scan (again) * ⚡ Improvements to #2021 * ⚡ Set scan to "false" by default to make it none breaking Co-authored-by: Michael Hirschler <michael.vhirsch@gmail.com> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
parent
a9987cd541
commit
56b82439cd
|
@ -301,26 +301,34 @@ export class AwsDynamoDB implements INodeType {
|
||||||
const simple = this.getNodeParameter('simple', 0, false) as boolean;
|
const simple = this.getNodeParameter('simple', 0, false) as boolean;
|
||||||
const select = this.getNodeParameter('select', 0) as string;
|
const select = this.getNodeParameter('select', 0) as string;
|
||||||
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
|
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 eanUi = this.getNodeParameter('additionalFields.eanUi.eanValues', i, []) as IAttributeNameUi[];
|
||||||
|
|
||||||
const body: IRequestBody = {
|
const body: IRequestBody = {
|
||||||
TableName: this.getNodeParameter('tableName', i) as string,
|
TableName: this.getNodeParameter('tableName', i) as string,
|
||||||
KeyConditionExpression: this.getNodeParameter('keyConditionExpression', i) as string,
|
|
||||||
ExpressionAttributeValues: adjustExpressionAttributeValues(eavUi),
|
ExpressionAttributeValues: adjustExpressionAttributeValues(eavUi),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (scan === true) {
|
||||||
|
body['FilterExpression'] = this.getNodeParameter('filterExpression', i) as string;
|
||||||
|
} else {
|
||||||
|
body['KeyConditionExpression'] = this.getNodeParameter('KeyConditionExpression', i) as string;
|
||||||
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
indexName,
|
indexName,
|
||||||
projectionExpression,
|
projectionExpression,
|
||||||
|
filterExpression,
|
||||||
} = this.getNodeParameter('options', i) as {
|
} = this.getNodeParameter('options', i) as {
|
||||||
indexName: string;
|
indexName: string;
|
||||||
projectionExpression: string;
|
projectionExpression: string;
|
||||||
|
filterExpression: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const expressionAttributeName = adjustExpressionAttributeName(eanUi);
|
const expressionAttributeName = adjustExpressionAttributeName(eanUi);
|
||||||
|
|
||||||
if (Object.keys(expressionAttributeName).length) {
|
if (Object.keys(expressionAttributeName).length) {
|
||||||
body.expressionAttributeNames = expressionAttributeName;
|
body.ExpressionAttributeNames = expressionAttributeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (indexName) {
|
if (indexName) {
|
||||||
|
@ -331,13 +339,17 @@ export class AwsDynamoDB implements INodeType {
|
||||||
body.ProjectionExpression = projectionExpression;
|
body.ProjectionExpression = projectionExpression;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filterExpression) {
|
||||||
|
body.FilterExpression = filterExpression;
|
||||||
|
}
|
||||||
|
|
||||||
if (select) {
|
if (select) {
|
||||||
body.Select = select;
|
body.Select = select;
|
||||||
}
|
}
|
||||||
|
|
||||||
const headers = {
|
const headers = {
|
||||||
'Content-Type': 'application/json',
|
'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') {
|
if (returnAll === true && select !== 'COUNT') {
|
||||||
|
@ -352,6 +364,7 @@ export class AwsDynamoDB implements INodeType {
|
||||||
if (simple === true) {
|
if (simple === true) {
|
||||||
responseData = responseData.map(simplify);
|
responseData = responseData.map(simplify);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Array.isArray(responseData)
|
Array.isArray(responseData)
|
||||||
|
|
|
@ -673,6 +673,38 @@ export const itemFields = [
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// Get All
|
// 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 <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-query-scan.html" target="_blank" >differences</a>',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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',
|
displayName: 'Key Condition Expression',
|
||||||
name: 'keyConditionExpression',
|
name: 'keyConditionExpression',
|
||||||
|
@ -689,6 +721,9 @@ export const itemFields = [
|
||||||
operation: [
|
operation: [
|
||||||
'getAll',
|
'getAll',
|
||||||
],
|
],
|
||||||
|
scan: [
|
||||||
|
false,
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -881,6 +916,13 @@ export const itemFields = [
|
||||||
displayName: 'Filter Expression',
|
displayName: 'Filter Expression',
|
||||||
name: 'filterExpression',
|
name: 'filterExpression',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
'/scan': [
|
||||||
|
false,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
default: '',
|
default: '',
|
||||||
description: 'Text that contains conditions that DynamoDB applies after the Query operation,<br>but before the data is returned. Items that do not satisfy the FilterExpression criteria</br>are not returned',
|
description: 'Text that contains conditions that DynamoDB applies after the Query operation,<br>but before the data is returned. Items that do not satisfy the FilterExpression criteria</br>are not returned',
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue