Working with the result of db.execute() (mysql2)

(TypeScript newbie here.) In my (SvelteKit) application I want to (health) check if certain database tables exist when the user visits the main page. What I tried:
const [ rows, fields] = await db.execute(
sql`SELECT table_name FROM information_schema.tables;`)

return {
tables: rows.map((x) => x.table_name).filter((x) => x.startsWith('virtual_'))
};
const [ rows, fields] = await db.execute(
sql`SELECT table_name FROM information_schema.tables;`)

return {
tables: rows.map((x) => x.table_name).filter((x) => x.startsWith('virtual_'))
};
But my rows.map() seems wrong. I get "Property 'map' does not exist on type 'ResultSetHeader'.". How would I properly work with the "rows" object?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server