fix: add no-prisma-delete lint

This commit is contained in:
DecDuck
2025-11-21 23:04:00 +11:00
parent f1fccd9bff
commit 650a3ca98d
18 changed files with 97 additions and 54 deletions

View File

@ -185,15 +185,19 @@ export class ClientHandler {
}
async removeClient(id: string) {
const client = await prisma.client.findUnique({ where: { id } });
if (!client) return false;
const ca = useCertificateAuthority();
await ca.blacklistClient(id);
// eslint-disable-next-line drop/no-prisma-delete
await prisma.client.delete({
where: {
id,
},
});
await userStatsManager.cacheUserStats();
return true;
}
}

View File

@ -378,12 +378,10 @@ class LibraryManager {
}
async deleteGameVersion(gameId: string, version: string) {
await prisma.gameVersion.delete({
await prisma.gameVersion.deleteMany({
where: {
gameId_versionName: {
gameId: gameId,
versionName: version,
},
gameId: gameId,
versionName: version,
},
});
@ -391,12 +389,12 @@ class LibraryManager {
}
async deleteGame(gameId: string) {
await prisma.game.delete({
await prisma.game.deleteMany({
where: {
id: gameId,
},
});
gameSizeManager.deleteGame(gameId);
await gameSizeManager.deleteGame(gameId);
}
async getGameVersionSize(

View File

@ -124,7 +124,10 @@ class NewsManager {
}
async delete(id: string) {
const article = await prisma.article.delete({
const article = await prisma.article.findUnique({ where: { id } });
if (!article) return false;
// eslint-disable-next-line drop/no-prisma-delete
await prisma.article.delete({
where: { id },
});
if (article.imageObjectId) {

View File

@ -259,16 +259,10 @@ class FsHashStore {
*/
async delete(id: ObjectReference) {
await this.cache.remove(id);
try {
// need to catch in case the object doesn't exist
await prisma.objectHash.delete({
where: {
id,
},
});
} catch {
/* empty */
}
await prisma.objectHash.deleteMany({
where: {
id,
},
});
}
}

View File

@ -53,12 +53,16 @@ class ScreenshotManager {
* @param id
*/
async delete(id: string) {
const deletedScreenshot = await prisma.screenshot.delete({
const screenshot = await prisma.screenshot.findUnique({ where: { id } });
if (!screenshot) return false;
// eslint-disable-next-line drop/no-prisma-delete
await prisma.screenshot.delete({
where: {
id,
},
});
await objectHandler.deleteAsSystem(deletedScreenshot.objectId);
await objectHandler.deleteAsSystem(screenshot.objectId);
return true;
}
/**

View File

@ -43,12 +43,12 @@ export default function createDBSessionHandler(): SessionProvider {
},
async removeSession(token) {
await cache.remove(token);
await prisma.session.delete({
const { count } = await prisma.session.deleteMany({
where: {
token,
},
});
return true;
return count > 0;
},
async cleanupSessions() {
const now = new Date();

View File

@ -101,19 +101,16 @@ class UserLibraryManager {
async collectionRemove(gameId: string, collectionId: string, userId: string) {
// Delete if exists
return (
(
await prisma.collectionEntry.deleteMany({
where: {
collectionId,
gameId,
collection: {
userId,
},
},
})
).count > 0
);
const { count } = await prisma.collectionEntry.deleteMany({
where: {
collectionId,
gameId,
collection: {
userId,
},
},
});
return count > 0;
}
async collectionCreate(name: string, userId: string) {
@ -133,12 +130,13 @@ class UserLibraryManager {
}
async deleteCollection(collectionId: string) {
await prisma.collection.delete({
const { count } = await prisma.collection.deleteMany({
where: {
id: collectionId,
isDefault: false,
},
});
return count > 0;
}
}