Tip on bulk insert query_

Hi any tip to achieve this using bulk inser query

i got the following form it users localstorage but, when im ready to generate document when i Press Generate button it should insert for every product line, one line in my postgresql db, so if i have 2 items, it should add two rows on a specific table in db.

what im doing wrong? i think issue is the fields that dont exist in my db with those names my table is like this, but how i can map fields from table to the real db table?

thank you

Hey @agaitan026!

If you're looking to change the names of your columns I imagine _.mapKeys might be a pretty good way to go. Does something like this work?

const tableData = {{ table2.data }};
const keyMappings = {
   key1_in_retool: "key1_in_db",
   key2_in_retool: "key2_in_db"
};
const keyMapper = (row) => _.mapKeys(row, (_, key) => keyMappings[key] ?? key);

return tableData.map(keyMapper);
1 Like

That will be a transformer right? I will try that