Skip to content

Commit 0964b1c

Browse files
committed
Clan.delete
1 parent 6c52318 commit 0964b1c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

backend/structures/Clan.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import Base from "./Base";
2+
13
// Clan structure in database
24
export interface ClanData {
35
name: string;
@@ -35,4 +37,12 @@ export default class Clan {
3537
this.name = data.name;
3638
this.tag = data.tag;
3739
}
40+
41+
public static delete(data: ClanData | string, base: Base): Promise<Array<any>> {
42+
const target: string = typeof data !== "string" ? data.name : data;
43+
return Promise.all([
44+
base.db.run("DELETE FROM clans WHERE name = ?", target),
45+
base.db.run("UPDATE accounts SET clan = ? WHERE clan = ?", null, target)
46+
]);
47+
}
3848
}

0 commit comments

Comments
 (0)