mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 02:51:14 +00:00
⚡ Improve update operation for Airtable
This commit is contained in:
@@ -373,6 +373,23 @@ export class Airtable implements INodeType {
|
|||||||
},
|
},
|
||||||
default: {},
|
default: {},
|
||||||
options: [
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Ignore Fields',
|
||||||
|
name: 'ignoreFields',
|
||||||
|
type: 'string',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
'/operation': [
|
||||||
|
'update',
|
||||||
|
],
|
||||||
|
'/updateAllFields': [
|
||||||
|
true,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
description: 'Comma separated list of fields to ignore.',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Typecast',
|
displayName: 'Typecast',
|
||||||
name: 'typecast',
|
name: 'typecast',
|
||||||
@@ -536,6 +553,16 @@ export class Airtable implements INodeType {
|
|||||||
if (updateAllFields === true) {
|
if (updateAllFields === true) {
|
||||||
// Update all the fields the item has
|
// Update all the fields the item has
|
||||||
body.fields = items[i].json;
|
body.fields = items[i].json;
|
||||||
|
|
||||||
|
if (options.ignoreFields && options.ignoreFields !== '') {
|
||||||
|
const ignoreFields = (options.ignoreFields as string).split(',').map(field => field.trim()).filter(field => !!field);
|
||||||
|
if (ignoreFields.length) {
|
||||||
|
// From: https://stackoverflow.com/questions/17781472/how-to-get-a-subset-of-a-javascript-objects-properties
|
||||||
|
body.fields = Object.entries(items[i].json)
|
||||||
|
.filter(([key]) => !ignoreFields.includes(key))
|
||||||
|
.reduce((obj, [key, val]) => Object.assign(obj, { [key]: val }), {});
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Update only the specified fields
|
// Update only the specified fields
|
||||||
body.fields = {} as IDataObject;
|
body.fields = {} as IDataObject;
|
||||||
|
|||||||
Reference in New Issue
Block a user