Add also "simple" option to Document->GetAll

This commit is contained in:
Jan Oberhauser 2021-07-18 14:21:30 +02:00
parent b531f31512
commit 5be8b6d5c2
2 changed files with 28 additions and 0 deletions

View file

@ -169,6 +169,17 @@ export class Elasticsearch implements INodeType {
responseData = await elasticsearchApiRequest.call(this, 'GET', `/${indexId}/_search`, body, qs); responseData = await elasticsearchApiRequest.call(this, 'GET', `/${indexId}/_search`, body, qs);
responseData = responseData.hits.hits; responseData = responseData.hits.hits;
const simple = this.getNodeParameter('simple', 0) as IDataObject;
if (simple) {
responseData = responseData.map((item: IDataObject) => {
return {
_id: item._id,
...(item._source as Object),
};
});
}
} else if (operation === 'create') { } else if (operation === 'create') {
// ---------------------------------------- // ----------------------------------------

View file

@ -247,6 +247,23 @@ export const documentFields = [
}, },
}, },
}, },
{
displayName: 'Simple',
name: 'simple',
type: 'boolean',
default: true,
description: 'Whether to return a simplified version of the response instead of the raw data',
displayOptions: {
show: {
resource: [
'document',
],
operation: [
'getAll',
],
},
},
},
{ {
displayName: 'Options', displayName: 'Options',
name: 'options', name: 'options',