Firebase record update error

The Firebase query panel doesn’t quite match the docs in “editing table values” section of the docs, which looks tailored for SQL.
(E.g., there is no Bulk Update action so I’m using the “Firestore Read/Write” action with the “Update document” Action Type.)
When I attempt to update the date using the
{{table1.recordUpdates}}
query, I get the following error:
Query Error (updateItems): Argument “data” is not a valid Document. Input is not a plain JavaScript object
thanks

1 Like

Hey Michael… just so I understand here, are you trying to do a bulk update to Firestore- or just update one doc?

The bulk updates for Firebase/store requires a few extra steps: @abdul-nimeri wrote a nice guide here: How to use the editable table feature with Firebase

Thanks for the heads up with the docs- I’ll fix that.

One doc at a time is fine – either done editing the current row or added a new one.

I tried doing each field manually, like so, but it doesn’t seem to pick up the new values:
{
foo: {{table1.selectedRow.data.foo}},

}

“The editable table feature has to work a bulk query” – ah ok. I’ll check out the article, thanx

You’re right that the {{table1.selectedRow.data.foo}}won’t pick up the new values… you could kind of hack it using table1.recordUpdates, which will pick up the new values, but I’d recommend trying the process in that article first.

Using that article’s script, I get “updateSingleRow is not defined”

Sorry - re-saved w/the new query name and now editing of existing rows seems to work. Now just need to get the Add New row to update correctly…

I can’t seem to get the new added row to get picked up – the bulk insert query from the article doesn’t error out, but doesn’t save any values either. I tried:

{
foo: {{table1.recordUpdates[0].foo}}
}
as a hack, but I guess I’m not on the right track there

For the new row adding- you’re going to want to a) make the columns editable, then b) make a new query to run “on row add” c) have that query reference {{table1.newRow}}

Keeping the bulk update queries separate from the insert queries will make your life simpler. Bulk updates use .recordUpdates, new row queries use .newRow

Thanks for the help Kent - my bad on newRow vs. recordUpdates – just started w/retool to bootstrap/manage a firebase for an new react app someone needs yesterday of course. Promise I’ll RTFM ASAP and will gladly use the paid version.

Oh no - trust me you’re not the first person to have trouble CRUDing with Firebase. Our docs could use some work in this area anyway, and we’ve got it planned for early 2020 (then I’ll tell people to rtfm). Happy to help, lmk if you need anything else!

Are there docs that go over the scripting nuances for queries? I thought that’s what I’d find in Queries>APIs, but that was “Web APIs” as a resource. E.g., what the various fields and fn’s are on the query object and how to use them properly? (Generically, and per-provider, such as Firebase for me at the moment.)

Is there a way to do a “View Source” for a query that is generated from the query GUI?

“view source” is fairly straightforward for SQL queries, but for Firebase we can approximate it by looking at the model browser.