I’ve been attempting to follow the Bulk Insert example app in order to insert data (all rows) from a table widget into a MySQL database. Where I’m getting stuck is in formatting. The following line works for lists using a single item as described in the sample:
let data = (${New_Users_List.items.map(item =>
'${item.user_name_input.text}').join("), (")})
;
I have been trying to make something similar work for a table. What I have gotten to work is using a for loop to break the table into its constituent rows, inserting each row one at a time (calling a query each time) as in the following screenshot:
However, what I would like to do is map all of the table data into SQL format, eg:
INSERT INTO sampleTable (id, value)
VALUES {{this.params.data}};
such that this.params.data looks like (id1, 100), (id2, 132), (id3, 111), etc.
Is there a better way to do this? Should I be doing multiple maps (one on a row level, one on a table level)? If so, what does that look like? I know this is a bit more of a JS question than an Appsmith question, but since it seems like something that others on the platform are likely to encounter, I thought I’d post here.
Thank you in advance for any help you can offer!