How to dynamically set a row value using data from a JS object? (onConflictDoUpdate)
I am:
.insert(myTable)
.values(data)
.onConflictDoUpdate({
target: [myTable.organisationId, myTable.financialAccountId],
set: data[0], // Putting [0] works but how to dynamically set the value to the relevant object in data array?
});
```
- Checking if a row already exists
- If it doesn't: Insert the
dataarray's object - If it exists: Update the price column - The issue is I'm not sure how to
seta row to the relevant object in mydataarray
```js
const data = [
{organisationId: "ABCD", accountId: "001", price: "120000"},
{organisationId: "EFGH", accountId: "002", price: "59000"},
];
.insert(myTable)
.values(data)
.onConflictDoUpdate({
target: [myTable.organisationId, myTable.financialAccountId],
set: data[0], // Putting [0] works but how to dynamically set the value to the relevant object in data array?
});
```