_mercury – 20-47 Jul 20

when try {} actually work in Js?
UU
Unknown User638d ago
G
ghardin137638d ago
when your code inside it throws an error?
M
_mercury638d ago
js error ? or db error ?
G
ghardin137638d ago
js error
M
_mercury638d ago
or pasrseInt? parseInt error?
G
ghardin137638d ago
parseInt probably won't throw an error it'll just return isNaN
M
_mercury638d ago
not good Like
const groups = await pool.query(
`
select g.* from groups g
left join attribute_groups ag on g.id = ag.group_id
left join attributes a on a.id = ag.attribute_id
where a.id = ?
`,
[attribute.id]
);
const groups = await pool.query(
`
select g.* from groups g
left join attribute_groups ag on g.id = ag.group_id
left join attributes a on a.id = ag.attribute_id
where a.id = ?
`,
[attribute.id]
);
how to make this code throw an error if there is no DB success
G
ghardin137638d ago
when you say db success what do you mean?
M
_mercury638d ago
I mean get valid results Actual rows not empty result [] or {}
G
ghardin137638d ago
that's not an error that's just there's nothing that matches it's a valid end state so you'd just need to check if that's the value yourself
M
_mercury638d ago
Ok thx
UU
Unknown User637d ago