0

I'm usinig mysql with express.

Usually I get one data from db for example :

const sql = 'select * from table where id = ?'

const [rows] = db.pool.execute(sql,param)

then I need to define like this to get the result object :

let mydata = rows[0]

is there any simpler way to define 'mydata' ?

2
  • It seems fairly simple?
    – Evert
    Commented Sep 8, 2021 at 2:10
  • How about destructuring the query result in the parameter as mentioned in this answer? Commented Sep 8, 2021 at 6:27

0

Browse other questions tagged or ask your own question.