auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
this.records = [
{
fields: {
"TEST": "TEST NAME",
},
id: "recOkepaWtxPRK5j5",
}
]
auths
objectAn array of update objects. Each of these objects should have two properties: 1) fields, which contains all of your record's cell values by field name, and 2) id, the ID of the record in Airtable you'd like to update. You can include all, some, or none of the field values.
Your Airtable Base ID
The name of your table in Airtable
return
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, params, auths) => {
}
const chunk = require('lodash.chunk');
const BATCH_SIZE = 10; // Airtable API allows to update up to 10 rows per request.
const { records } = params
if (!records || !records.length) {
console.log("No records found")
return
}
const size = records.length;
const response_records = []
async function updateRecords(records){
const config = {
method: "patch",
url: `https://api.airtable.com/v0/${params.base_id}/${encodeURIComponent(params.table_name)}`,
headers: {
Authorization: `Bearer ${auths.airtable.api_key}`,
},
data: {
records,
typecast: params.typecast,
}
};
return await require("@pipedreamhq/platform").axios(this, config);
};
const records_sets = chunk(records, BATCH_SIZE);
for (const records_set of records_sets) {
response_records.push(await updateRecords(records_set));
}
return response_records;