aboutsummaryrefslogtreecommitdiffstats
path: root/db.js
diff options
context:
space:
mode:
authorpack <pack@packgekko.xyz>2026-08-12 17:06:50 +0000
committerpack <pack@packgekko.xyz>2026-08-12 17:06:50 +0000
commit5611527e313c4add16c432e5cf9d55a987558c02 (patch)
tree59ad054325096b6305277b94982bbe7f7f585f59 /db.js
parentd3adc16a08d95d6e331de55d7d3bf05a66a874a8 (diff)
downloadcrud-5611527e313c4add16c432e5cf9d55a987558c02.tar.gz
final commit
Diffstat (limited to 'db.js')
-rw-r--r--db.js28
1 files changed, 20 insertions, 8 deletions
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;