An example of Bulk Update query via Google Sheets

There doesn’t seem to be much of documentation around this. Can someone help with an example?
Resource: Google sheets
usecase: edit a cell in the table and trigger a save.

@abdul-nimeri Any suggestion?

hi! yeah i wish we had an easier way to do this… we built this feature with postgres / sql dbs in mind, which come with bulk updates by default. but using this with other resources has been tricky

have you seen this thread by any chance? How to use the editable table feature with Firebase

the instructions are for firebase, but the core idea is the same:

  1. google sheets query to update a single row
  2. JS query to loop over all the changed rows and run the google sheets query

Yes … would be really helpful having an example since this is a pretty common use case I would think. I’m trying to figure it out now.

1 Like

Would love to see this. Struggling with the same problem now

1 Like

Me too. I would like to export a postgres table into a Google Sheet. I thought this would be possible with Retool :thinking:

I guess my alternative for now is using the Google Sheets API

Hi All!

I've had some time here to add an example to our Google Sheets Tutorial after the Displaying data in a table section! I still need to update the other sections to our latest UI changes, but I wanted to get this new section written for everyone first.

We'll need to use a single update query filtering by a primary key for the table and a Run JS Code type query to loop through each change. We'll set that JS query as the "Bulk update action" under the "Table Edit Queries" section of the table settings.

Here's that code:

const updates =  table1.recordUpdates.map((d,i)=>{
  updateRow.trigger({
    additionalScope: {"i":i},
    onSuccess: function(data){
      if( i == table1.recordUpdates.length-1){
        readSheets.trigger()
      }
    }
  }); 
})

return Promise.all(updates)

In this case, readSheets is our primary query which is used to display the data in our table component. We'll re-trigger that onSuccess of the final update to display our newly changed data in the table.

@nacho This setup should be able to be modified to loop through any array instead of table1.recordUpdates. For a postgres query, you could replace that with formatDataAsArray(query1.data).

Also @JaredSyrg @joshuasilver

2 Likes