I’m trying to get the result of an exists query using typescript but I can’t get the ‘1’ or ‘0’ of the object that the query is returning.
code.ts
const rslt1 = query(`SELECT EXISTS(SELECT * FROM patients WHERE cc=?)`, [params.ccInput]);
const rslt2 = query(`SELECT EXISTS(SELECT * FROM doctors WHERE specialty=?)`, [params.specialtyInput]);
(async () => {
const frslt1:object = await rslt1
console.log(frslt1, Object.values(frslt1))
console.log(await rslt2)
})()
In the console I just get this:
[{ "EXISTS(SELECT * FROM patients WHERE cc='6465465465')": 0 } ] [ { "EXISTS(SELECT * FROM patients WHERE cc='6465465465')": 0 } ]
[{ "EXISTS(SELECT * FROM doctors WHERE specialty='Medicina general')": 1 } ]
I need the result of the query to do an if later
2
Answers
How it worked for me was this:
code.ts
In console I get this:
I think you should try to put the
query
call into your async function directly.Try