forked from Ananya-te/MusicTrackerAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.js
More file actions
25 lines (21 loc) · 605 Bytes
/
db.js
File metadata and controls
25 lines (21 loc) · 605 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database('./music.db');
db.serialize(() => {
db.run(`CREATE TABLE IF NOT EXISTS songs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT,
artist TEXT,
genre TEXT
)`);
db.run(`CREATE TABLE IF NOT EXISTS playlists (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT
)`);
db.run(`CREATE TABLE IF NOT EXISTS playlist_songs (
playlist_id INTEGER,
song_id INTEGER,
FOREIGN KEY(playlist_id) REFERENCES playlists(id),
FOREIGN KEY(song_id) REFERENCES songs(id)
)`);
});
module.exports = db;