Auto create primary key

I created an editable table in retool. You can input the number of rows you want and fetch
The table is editable, so I need a primary key to be able to use change changesetArray function.

How do I create a primary key now. They are not editable, they need to be auto generated

I think you would need to set that up in the database....

1 Like

Hey @Chilaka!

Would you mind sharing the code for your createRows query? I'm also curious to hear more about how you're using this editable table! Where do the user entries go?

@Kabirdas thanks for responding.

I have deleted the set up cos I found a way around that. But what I did was create a table component with rows serial, item cost per item and quantity. The JS query add the number of rows to table1. Columns in the table are editable (except the one I set as pk)

Entries go to a google sheet on save action

Ahh I see. JS queries are interesting because there's a lot to you can do to generate id's. For instance Retool comes with the uuid library built in, so you can use uuid.v4() to generate an id. How you actually want to do it depends on how you have your DB set up though.

Glad to hear you were able to find a workaround and thanks for sharing!

1 Like