loopbackio/loopback-connector-postgresql

native SQL update query to update columns in a table

visdevabhakt opened this issue · 0 comments

Hi,

I'm using Postgresql connector and dataSource.execute() to run the SQL Update query.I have written the code as follows. I'm getting an error, error: syntax error at or near "=". Is this not correct syntax?

Error details:

name: 'error',
length: 90,
severity: 'ERROR',
code: '42601',
detail: undefined,
hint: undefined,
position: '62',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'scan.l',
line: '1134',
routine: 'scanner_yyerror'

code:

let params = [1, 923];
const query =
'UPDATE organisation_config' +
'SET ' +
'notifications= $1' +
'where id= $2';
try {
const result = this.repo.execute(query, [params], {});
return result;
} catch (err) {
console.error('Error in update', err);
}