Refactoring commit--working
This commit is contained in:
parent
bc8c1b1c54
commit
69ccaa7560
@ -22,7 +22,8 @@ export async function initGameDB(): Promise<any> {
|
||||
sequelize: undefined,
|
||||
Sequelize: undefined,
|
||||
getGameById: async (_id: string | number) => null,
|
||||
saveGameState: async (_id: string | number, _state: GameState) => { /* no-op */ }
|
||||
saveGameState: async (_id: string | number, _state: GameState) => { /* no-op */ },
|
||||
deleteGame: async (_id: string | number) => { /* no-op */ }
|
||||
} as any;
|
||||
}
|
||||
// If the module uses default export, prefer it
|
||||
@ -80,5 +81,19 @@ export async function initGameDB(): Promise<any> {
|
||||
};
|
||||
}
|
||||
|
||||
if (!db.deleteGame) {
|
||||
db.deleteGame = async (id: string | number): Promise<void> => {
|
||||
if (db && db.sequelize) {
|
||||
try {
|
||||
await db.sequelize.query('DELETE FROM games WHERE id=:id', {
|
||||
replacements: { id }
|
||||
});
|
||||
} catch (e) {
|
||||
// swallow errors; callers will rely on fallback behavior
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return db;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user