Here is my server mcve:
const express = require("express");
const app = express();
const fs = require("fs");
const dbFile = "./sqlite.db";
const exists = fs.existsSync(dbFile);
const sqlite3 = require("sqlite3").verbose();
const db = new sqlite3.Database(dbFile);
app.get("/", async (req, resp) => {
await db.run(`INSERT INTO Times VALUES (${ Date.now() })`);
let rows = await db.all("SELECT time FROM Times");
console.log(rows); // The line where I console log rows
resp.send(rows);
});
app.listen(process.env.PORT || 8080);
process.on("uncaughtException", console.log);
The above server is logging a database object like so,
Database {}
in console every time I refresh the site, but I expect it to log the row which I've inserted in the database.
What I'm doing wrong here?
.run
and other methods too in sqlite3? – Rollerskate