async adminAddEmp(req, res){
const emp_password = crypto.createHash('sha256').update(req.body.emp_password).digest('hex')
const {first_name, last_name, emp_position, salary, login} = req.body
await userController.current.query(`CREATE USER $1 WITH PASSWORD \'$2\'IN ROLE $3`, [login, emp_position, emp_password])
await userController.current.query(`INSERT INTO employee (first_name, last_name, emp_position, salary, login, emp_password)
VALUES ($1, $2, $3, $4, $5, $6)`, [first_name, last_name, emp_position, salary, login, emp_password])
res.json(user added) }
When I am trying to make this request I have an UnhandledPromiseRejectionWarning: error because of "$1" symbol syntax error. I think that it's because node js make this request with quotes (like CREATE "temp" USER WITH PASSWORD "password" in ROLE "role") and this is problem because temp and role must be without quotes.
There is no problem with INSERT request by the way. So problem is quotes in CREATE USER request.
How can I make request like this?
Thanks.