-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqlite.js
More file actions
29 lines (22 loc) · 843 Bytes
/
sqlite.js
File metadata and controls
29 lines (22 loc) · 843 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
26
27
28
29
const sqlite3 = require('sqlite3').verbose();
class sqlite {
constructor(){
this.db = new sqlite3.Database("./db.sqlite3");
}
createPlayer(player, callback){
const stmt = this.db.prepare("INSERT INTO player VALUES (?, ?, ?, ?, ?, ?)");
stmt.run(player.extra.UserID, player.UName, player.extra.IPAddress, player.extra.Language, new Date().toISOString().slice(0, 19).replace('T', ' '), 0)
stmt.finalize();
callback()
}
playerExist(UserID, callback){
this.db.each("SELECT count(*) as count FROM player where UserID = " + UserID, callback);
}
req(req, args, callback){
this.db.each(req, args, callback);
}
$(req, args, callback){
this.db.all(req, args, callback);
}
}
module.exports = { sqlite: sqlite };