The editable table feature has to work a bulk query, i.e. a query that’s able to change many columns and many rows, all at once! this works easily with our sql integration since we have an explicit bulk update option, but for firebase we’ll need to do a little more work.
we’ll need three queries:
- fetchCollection: get our data from firebase
- updateSingleRow: a firebase query to update a single row
- bulkUpdateRows: a JS query to loop thru every updated row and call the updateSingleRow query
here’s what they look like:
here’s the JS code forbulkUpdateRows
:
return Promise.all( table1.recordUpdates.map(record => updateSingleRow.trigger({ additionalScope: { _id: record._id, changeSet: _.omit(record, ['__metadata', '_id']), } }) ) )
note that we setupfetchCollection
to run afterbulkUpdateRows
, so that our table refreshes with the new data after we update it!
once you have thebulkUpdateRows
query, you can follow the rest of our editable table instructions here!