Update specific column of specific row

Working with the coda-js wrapper for the API.

I want to update a specific cell, and I know the docId, tableId, rowId, and columnId in question. The examples I’ve found seem to require getting the whole row’s cells, and then writing them back again via the API with any changes included. Is this necessary, or can I just specify a new value for a single cell? Something like:

coda.updateRow( docId, tableId, rowId, {columnId: value} );

Edit: Had a different error that was causing the above not to work. In fact, it it precisely the correct way to do it :slight_smile: Will leave here in case helpful for others.

Further edit: if you prefer, you can also go do an array of objects like this:

coda.updateRow( docId, tableId, rowId, [
      {column: 'id or name', value: 'value'},
      {column: 'another id', value: 'another value'}
]);

Hey @Nick_HE can you share how you’re using the coda-js wrapper? I’m trying to learn ways to extend Coda. Thanks

I mostly use the API to either:

  • Format data from Coda in a pretty (or very specific) way, for printing to PDF
  • Use Coda as an admin interface, and then provide access to a slice of Coda data to someone that I don’t want to invite into the whole doc (e.g. Coda doc for booking staff; staff can see just their own info via API)

In terms of my stack:

  • I’m running coda-js in Firebase Cloud Functions (if you’re not familiar - cloud functions are a trendy way to handle server-side code; instead of a full backend app running on a machine somewhere, you just have individual functions that are encapsulated as their own little micro-apps. Lots of modern hosts let you do this, and Google’s Firebase is one of them)
  • Usually I’ll make a little Vue.js app as the front-end, that interacts with the cloud functions
  • If it’s something very simple, I’ll skip the front-end app entirely and serve some basic HTML directly from the cloud function

Caveats:

  • While you can kiiiiinda use Coda as the backend database for a site/app, it’s really not built for that!
  • It’s not super fast (e.g. a round-trip from my Vue app asking Firebase cloud functions to pull 4 rows from Coda in one request is clocking around 5 seconds)
  • There is a significant delay (15-20sec) between when data is updated in the Coda doc, and when it’s updated in the API’s view of things. So if you update a cell in your doc, and then get it via the API 10 seconds later, it will still show the old value.

Let me know if you have any questions. What kind of stuff are you looking to do?

2 Likes