const query = {
text: 'INSERT INTO users(name, email) VALUES($1, $2)',
values: ['brianc', 'brian.m.carlson@gmail.com'],
}
const res = await client.query(query)
console.log(res.rows[0])
const text = 'INSERT INTO users(name, email) VALUES($1, $2) RETURNING *'
const values = ['brianc', 'brian.m.carlson@gmail.com']
const res = await client.query(text, values)
const query = {
text: `SELECT pr.printer_id, m.material
FROM printer_material pm
JOIN printer pr ON pm.printer_id = pr.printer_id
JOIN material m ON pm.material_id = m.material_id
WHERE pr.printer_id = $1,
values: [printer_id],`
};
run promise
error catched in .catch
Methods with the same name as their class will not be constructors in a future version of PHP;
response.status(200).json([...results.rows]);
Самому в массив конвертировать.