I use knex to update and returning number of rows been updated. It seems that knex returning update return unknown[]. But when I do checking using typeof it is actually number.
But apparently Typescript not allowed me to simply convert it.
So below is the solution.
1 2 3 4 5 |
//change the unknown[] to number[] const result = await query.run() as number[]; //check if result is array, and do proper conversion const result1 = (Array.isArray(result)) ? result[0]: result; |