ptSend/util/sql/base.js
2023-06-29 22:00:07 +08:00

39 lines
803 B
JavaScript

const sqlite = require("sqlite3")
const path = require("path");
const { cwd } = require("process");
let p = path.join(cwd(),"/db/database.db")
database = new sqlite.Database(p, function(err) {
if (err) throw err;
});
function run(){
let args = arguments
console.log(args)
return new Promise((res,err)=>{
database.run(...args,(error)=>{
if(error){
err(error)
}else{
res("添加成功")
}
})
})
}
function getAll(){
let args = arguments
return new Promise((res,err)=>{
database.all(...args,function (error,data){
if(error){
err(error)
}else{
res(data)
}
})
})
}
module.exports = {
run,
getAll
}