-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
29 lines (26 loc) · 834 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var Airtable = require('airtable');
const config = require("./config.json");
var base = new Airtable({apiKey: config["apiKey"]}).base(config["baseURL"]);
config["tables"].forEach((table) => {
base(table["name"]).select({
pageSize:10,
}).eachPage(function page(records, fetchNextPage){
var updateArr = [];
var updateObj = {};
records.forEach(function(record){
updateObj = {};
updateObj["id"] = record["id"];
updateObj["fields"] = table["fields"];
updateArr.push(updateObj);
});
base(table["name"]).update(updateArr, (error) => {
// results have been updated
console.log(error);
fetchNextPage(); // gets the next block
});
fetchNextPage();
},function done(err) {
console.log("done");
if (err) { console.error(err); return; }
});
});