Needing to exclude my table key of ID when posting an update through JsonSchemaForm

The GetWorkOrders query reads data from a Retool Database that is populated into Table1.

My Retool Database sheet "Workorders" has a primary key for column 0 that the database automatically increments as new rows are added.

Table edits (by single row) are handled by passing the data from the selected row to update to jsonSchemaForm1. jsonSchemaForm1 has an update button with an event handler that triggers QueryUpdateWorkOrder.

I can map the key value pairs and the update works just fine but this is because I do not try to write to the primary key column of "ID".

As I'll be using similar projects over and over I'd like to be able to use the form object to handle updates. When I use the object {{ [] }} I end up with an error

 "workorders" set "0" = $1 where "id" = $2 returning * - column "0" of relation "workorders" does not exist

I believe it is because the id is also getting passed with the object and since the database does not allow me to write to the id column i believe this is where the issue arises.

Is there a way to remove id from the object being updated? I still need the id to filter by for the update but would like to be able to exclude it from the object (line data in database getting updated)

I have tried various forms of:

  • {{delete}}
  • {{ [] }}

for the changeset object but get this error

Empty .update() call detected! Update data does not contain any values to update. This will result in a faulty query. Table: workorders. Columns: delete[id] [object Object].

I can go back and map each individual key value pair each time (excluding the entry for id) but am wondering if there is an easier way to use the data from the form object where it works with a retool database that has primary key built into the database

Hey @Nate_Sikkenga!

Have you tried using lodash's _.omit function? Something like this for example:

{{ [ _.omit(, ["id"]) ] }} 

It comes built-in with Retool!

1 Like

Sounds like that would make it easy. Thanks!!

I seem to still be having the same issue. I can declare each key and update fine with key value pairs. It doesn't seem to like select1 (a selectbox that references values 1-2 for "To Do", "Parts Ordered" or "Complete") or id (column 0 - default key in retool database)

Hmm... you should be able to pass multiple components in the same _.omit call. You might also want to remove the [] from around the expression. Does something like this work?

{{ _.omit(, ["select1", "id"]) }}