1
0
forked from w0bm/f0bm

change psql-lib from knex to postgres.js

This commit is contained in:
Flummi
2022-03-31 13:34:51 +02:00
parent f750a9a60f
commit c498a33cbe
20 changed files with 689 additions and 973 deletions

View File

@@ -1,5 +1,5 @@
import { promises as fs } from "fs";
import sql from "../sql.mjs";
import db from "../sql.mjs";
export default async bot => {
@@ -14,14 +14,22 @@ export default async bot => {
if(id <= 0)
return false;
const f0ck = await sql("items").select("dest").where("id", id).limit(1);
const f0ck = await db`
select dest
from "items"
where id = ${+id}
limit 1
`;
if(f0ck.length === 0)
return false;
await fs.unlink(`./public/b/${f0ck[0].dest}`).catch(_=>{});
await fs.unlink(`./public/t/${id}`).catch(_=>{});
await sql("items").where("id", id).del().limit(1);
await db`
delete from "items"
where id = ${+id}
`;
return id;
}))).filter(d => d);