I use "mysql": "^2.18.1"
on NodeJs.
I have a query that resembles
updateProperty: `UPDATE object SET property = ? WHERE id = ?;`
. In code I have a lot of objects of each I want to update the property each x seconds
so I thought I would just concat the query like:
let query = "";
let args = [];
for(const obj of objects){
query += updateProperty;
args.push(obj.property);
args.push(obj.id);
}
and then use DB.query(query, args, (err: any) => { ... })
but I get You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version
in this case.
I also tried replacing in the query directly with replace("?", obj.property)
etc but encounter the same error.
Is there a "better" way to approach this?