mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
🐛 Fix bug when updating and deleting records (#1532)
This commit is contained in:
@@ -137,7 +137,7 @@ export class Airtable implements INodeType {
|
|||||||
// delete
|
// delete
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
{
|
{
|
||||||
displayName: 'Id',
|
displayName: 'ID',
|
||||||
name: 'id',
|
name: 'id',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
@@ -317,7 +317,7 @@ export class Airtable implements INodeType {
|
|||||||
// read
|
// read
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
{
|
{
|
||||||
displayName: 'Id',
|
displayName: 'ID',
|
||||||
name: 'id',
|
name: 'id',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
@@ -336,7 +336,7 @@ export class Airtable implements INodeType {
|
|||||||
// update
|
// update
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
{
|
{
|
||||||
displayName: 'Id',
|
displayName: 'ID',
|
||||||
name: 'id',
|
name: 'id',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
@@ -499,7 +499,7 @@ export class Airtable implements INodeType {
|
|||||||
for (let i = 0; i < items.length; i++) {
|
for (let i = 0; i < items.length; i++) {
|
||||||
id = this.getNodeParameter('id', i) as string;
|
id = this.getNodeParameter('id', i) as string;
|
||||||
|
|
||||||
endpoint = `${application}/${table}/${id}`;
|
endpoint = `${application}/${table}`;
|
||||||
|
|
||||||
// Make one request after another. This is slower but makes
|
// Make one request after another. This is slower but makes
|
||||||
// sure that we do not run into the rate limit they have in
|
// sure that we do not run into the rate limit they have in
|
||||||
@@ -507,9 +507,11 @@ export class Airtable implements INodeType {
|
|||||||
// functionality in core should make it easy to make requests
|
// functionality in core should make it easy to make requests
|
||||||
// according to specific rules like not more than 5 requests
|
// according to specific rules like not more than 5 requests
|
||||||
// per seconds.
|
// per seconds.
|
||||||
|
qs.records = [id];
|
||||||
|
|
||||||
responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||||
|
|
||||||
returnData.push(responseData);
|
returnData.push(...responseData.records);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (operation === 'list') {
|
} else if (operation === 'list') {
|
||||||
@@ -586,7 +588,6 @@ export class Airtable implements INodeType {
|
|||||||
let updateAllFields: boolean;
|
let updateAllFields: boolean;
|
||||||
let fields: string[];
|
let fields: string[];
|
||||||
let options: IDataObject;
|
let options: IDataObject;
|
||||||
|
|
||||||
for (let i = 0; i < items.length; i++) {
|
for (let i = 0; i < items.length; i++) {
|
||||||
updateAllFields = this.getNodeParameter('updateAllFields', i) as boolean;
|
updateAllFields = this.getNodeParameter('updateAllFields', i) as boolean;
|
||||||
options = this.getNodeParameter('options', i, {}) as IDataObject;
|
options = this.getNodeParameter('options', i, {}) as IDataObject;
|
||||||
@@ -616,13 +617,9 @@ export class Airtable implements INodeType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.typecast === true) {
|
|
||||||
body['typecast'] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
id = this.getNodeParameter('id', i) as string;
|
id = this.getNodeParameter('id', i) as string;
|
||||||
|
|
||||||
endpoint = `${application}/${table}/${id}`;
|
endpoint = `${application}/${table}`;
|
||||||
|
|
||||||
// Make one request after another. This is slower but makes
|
// Make one request after another. This is slower but makes
|
||||||
// sure that we do not run into the rate limit they have in
|
// sure that we do not run into the rate limit they have in
|
||||||
@@ -631,9 +628,11 @@ export class Airtable implements INodeType {
|
|||||||
// according to specific rules like not more than 5 requests
|
// according to specific rules like not more than 5 requests
|
||||||
// per seconds.
|
// per seconds.
|
||||||
|
|
||||||
responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
const data = { records: [{ id, fields: body.fields }], typecast: (options.typecast) ? true : false };
|
||||||
|
|
||||||
returnData.push(responseData);
|
responseData = await apiRequest.call(this, requestMethod, endpoint, data, qs);
|
||||||
|
|
||||||
|
returnData.push(...responseData.records);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa
|
|||||||
body,
|
body,
|
||||||
qs: query,
|
qs: query,
|
||||||
uri: uri || `https://api.airtable.com/v0/${endpoint}`,
|
uri: uri || `https://api.airtable.com/v0/${endpoint}`,
|
||||||
|
useQuerystring: false,
|
||||||
json: true,
|
json: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user