I want to make a basic website with a local persistent database. I'm using sql.js but it seems that it's saving the data to webstorage instead of the .db file. Is my code wrong or is sql.js. Is sql.js not the right tool for this job or is my code bad?
This is my code:
async function initializeDatabase() {
const sqlPromise = initSqlJs({
locateFile: () => `src/modules/sql-wasm.wasm`
});
const dataPromise = fetch("src/db/sql2.db").then(res => res.arrayBuffer());
const [SQL, buf] = await Promise.all([sqlPromise, dataPromise]);
const db = new SQL.Database(new Uint8Array(buf));
db.run("CREATE TABLE IF NOT EXISTS items (id INTEGER PRIMARY KEY, quantity INTEGER)")
db.exec("INSERT INTO items (id, quantity) VALUES (32, 34)")
}