forked from iwestlin/gd-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.js
More file actions
21 lines (18 loc) · 607 Bytes
/
db.js
File metadata and controls
21 lines (18 loc) · 607 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const path = require('path')
const db_location = path.join(__dirname, 'gdurl.sqlite')
const db = require('better-sqlite3')(db_location)
db.pragma('journal_mode = WAL')
module.exports = { db }
create_table_copied()
function create_table_copied () {
const [exists] = db.prepare('PRAGMA table_info(copied)').all()
// console.log('exists', exists)
if (exists) return
const create_table = `CREATE TABLE "copied" (
"taskid" INTEGER,
"fileid" TEXT
)`
db.prepare(create_table).run()
const create_index = `CREATE INDEX "copied_taskid" ON "copied" ("taskid");`
db.prepare(create_index).run()
}