Create Doc
var doc = CodaAPI.createDoc({title: 'Coda API Starter Tutorial'});
Logger.log('New doc created! %s', prettyPrint(doc, null, 2));
var doc = CodaAPI.createDoc({title: 'Coda API Starter Tutorial'});
Logger.log('New doc created! %s', prettyPrint(doc, null, 2));
List Tables
var tables = CodaAPI.listTables(DOC_ID);
Logger.log('Doc tables are: %s', prettyPrint(tables));
var tables = CodaAPI.listTables(DOC_ID);
Logger.log('Doc tables are: %s', prettyPrint(tables));
List Columns
var columns = CodaAPI.listColumns(DOC_ID, TABLE_ID);
Logger.log('Columns are: %s', prettyPrint(columns, null, 2));
var columns = CodaAPI.listColumns(DOC_ID, TABLE_ID);
Logger.log('Columns are: %s', prettyPrint(columns, null, 2));
Get Desired Cities
var rowsResponse = CodaAPI.listRows(DOC_ID, TABLE_ID);
var cities = [];
for (var row of rowsResponse.items) {
cities.push(row.values[CITY_COLUMN_ID]);
}
Logger.log('Fetched cities from Coda: %s', prettyPrint(cities));
return cities;
var rowsResponse = CodaAPI.listRows(DOC_ID, TABLE_ID);
var cities = [];
for (var row of rowsResponse.items) {
cities.push(row.values[CITY_COLUMN_ID]);
}
Logger.log('Fetched cities from Coda: %s', prettyPrint(cities));
return cities;
Satellite Final
var cities = getDesiredCities();
var rows = [];
for (var city of cities) {
var satImage = getSatelliteImageUrl(city);
rows.push({
cells: [
{column: CITY_COLUMN_ID, value: city},
{column: IMAGE_URL_COLUMN_ID, value: satImage},
],
});
}
var body = {
rows: rows,
keyColumns: [CITY_COLUMN_ID],
};
CodaAPI.upsertRows(DOC_ID, TABLE_ID, body);
var cities = getDesiredCities();
var rows = [];
for (var city of cities) {
var satImage = getSatelliteImageUrl(city);
rows.push({
cells: [
{column: CITY_COLUMN_ID, value: city},
{column: IMAGE_URL_COLUMN_ID, value: satImage},
],
});
}
var body = {
rows: rows,
keyColumns: [CITY_COLUMN_ID],
};
CodaAPI.upsertRows(DOC_ID, TABLE_ID, body);