From 5611527e313c4add16c432e5cf9d55a987558c02 Mon Sep 17 00:00:00 2001 From: pack Date: Wed, 12 Aug 2026 17:06:50 +0000 Subject: final commit --- db.js | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'db.js') diff --git a/db.js b/db.js index 1ca5195..468441a 100644 --- a/db.js +++ b/db.js @@ -1,9 +1,21 @@ -const sqlite3 = require('sqlite3').verbose(); -const db = new sqlite3.Database('./app.db'); -db.serialize(() => { - db.run(`CREATE TABLE IF NOT EXISTS users ( - id INTEGER PRIMARY KEY, username TEXT UNIQUE, password TEXT)`); - db.run(`CREATE TABLE IF NOT EXISTS items ( - id INTEGER PRIMARY KEY, user_id INTEGER, title TEXT, content TEXT)`); -}); +const Database = require('better-sqlite3'); +const db = new Database('./crud.db'); + +db.exec(` + CREATE TABLE IF NOT EXISTS users ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + username TEXT UNIQUE NOT NULL, + password TEXT NOT NULL + ); + + CREATE TABLE IF NOT EXISTS tasks ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + user_id INTEGER NOT NULL, + title TEXT NOT NULL, + description TEXT, + done INTEGER DEFAULT 0, + FOREIGN KEY (user_id) REFERENCES users(id) + ) +`); + module.exports = db; -- cgit v1.2.3