-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb.js
56 lines (42 loc) · 1.54 KB
/
db.js
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const { Sequelize,QueryTypes } = require('sequelize');
const sequelize = new Sequelize({
dialect: 'sqlite',
storage: __dirname+'/gensquid_impact.db',
pool: {
max: 5,
min: 0,
idle: 10000
},
});
console.log(__dirname+'/gensquid_impact.db')
const select = async function(sql,callback){
return await sequelize.query(sql, { type: QueryTypes.SELECT }).then(callback)
};
module.exports.select=select;
const insert = async function(sql,callback){
return await sequelize.query(sql, { type: QueryTypes.INSERT }).then(callback)
};
module.exports.insert=insert;
const update = async function(sql,callback){
return await sequelize.query(sql, { type: QueryTypes.UPDATE }).then(callback)
};
module.exports.update=update;
const del = async function(sql,callback){
return await sequelize.query(sql, { type: QueryTypes.DELETE }).then(callback)
};
module.exports.delete=del;
const query = async function(sql){
return await sequelize.query(sql).then((res)=> {
return res
});
}
module.exports.query=query;
async function test(){
await del("DELETE FROM PLAYERS WHERE ID='360438506595549214'");
await select("SELECT * from PLAYERS",console.log);
await insert("INSERT INTO PLAYERS(ID,NAME) VALUES ('360438506595549214','un_phoque')",console.log);
await select("SELECT * from PLAYERS",console.log);
await update("UPDATE PLAYERS SET SEASNAILS=500 where ID='360438506595549214'")
await select("SELECT * from PLAYERS",console.log);
}
//test()