I am currently working with an array of objects in order to create an Update SQL statement. Here is the array I am using:
let dataUpdate = [
{
"field1":123,
"field2":"BMW",
"field3":"blue"
}
]
This is my attempted approach:
let query: string = `UPDATE dataset.table SET` + dataTest.forEach((item:any) =>
Object.entries(item).map(([key,value]) => {
`${key} = '${value}'`
}).join(',')
)
After running this code, I end up with:
UPDATE dataset.table SETundefined
What I actually want to achieve is:
UPDATE dataset.table SET field2="BMW", field3="blue" WHERE field1=123