forked from noxious/server
Ah
This commit is contained in:
@ -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();
|
Reference in New Issue
Block a user