Issue
I am able to query the DB and get info back but when I try to insert a row in an SQLite DB , I get an empty response.
My query that returns something:
const response = await sql('SELECT * FROM work_orders ORDER BY CASE WHEN status = "OPEN" THEN 1 WHEN status = "CLOSED" THEN 2 ELSE 3 END')
and the insertion that won't work:
const response = await sql('INSERT INTO work_orders (name, status) VALUES (?, "OPEN")', workOrderName);
return res.status(201).json({ response });
What could I be missing?
the table was created with id INTEGER PRIMARY KEY AUTOINCREMENT
Solution
I dont really know SQLite but maybe if you try RETURNING *, it may work.
const response = await sql('INSERT INTO work_orders (name, status) VALUES (?, "OPEN") RETURNING *', workOrderName);
return res.status(201).json({ response });
Answered By - Fabien Brocklesby Answer Checked By - Gilberto Lyons (sql.easybugfix Admin)
Post a Comment
Post a Comment