1
0
forked from noxious/server
This commit is contained in:
2024-07-11 19:57:52 +02:00
parent 218ac385dd
commit 7475b83179
2 changed files with 4 additions and 50 deletions

View File

@ -1,45 +0,0 @@
import prisma from '../utilities/Prisma'; // Import the global Prisma instance
import { TileTag } from '@prisma/client'
class TileTagRepository {
async upsertTileTag(tile: string, tags: string[]): Promise<TileTag> {
return prisma.tileTag.upsert({
where: { tile },
create: {
tile,
tags: tags,
},
update: {
tags: tags,
},
});
}
async getTileTag(tile: string): Promise<TileTag | null> {
return prisma.tileTag.findUnique({
where: { tile },
});
}
async deleteTileTag(tile: string): Promise<TileTag> {
return prisma.tileTag.delete({
where: { tile },
});
}
async searchTilesByTags(tags: string[]): Promise<TileTag[]> {
return prisma.tileTag.findMany({
where: {
tags: {
array_contains: tags,
} as any, // Type assertion needed due to Json field
},
});
}
async getAllTileTags(): Promise<TileTag[]> {
return prisma.tileTag.findMany();
}
}
export default new TileTagRepository();