feat: implement initial database schema and services for authentication, restaurants, categories, and menu items with image support.
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Category" ADD COLUMN "image" TEXT;
|
||||||
@@ -97,6 +97,7 @@ model Restaurant {
|
|||||||
model Category {
|
model Category {
|
||||||
id String @id @default(uuid())
|
id String @id @default(uuid())
|
||||||
name String
|
name String
|
||||||
|
image String?
|
||||||
|
|
||||||
restaurantId String
|
restaurantId String
|
||||||
restaurant Restaurant @relation(fields: [restaurantId], references: [id], onDelete: Cascade)
|
restaurant Restaurant @relation(fields: [restaurantId], references: [id], onDelete: Cascade)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export class CategoryService {
|
|||||||
const category = await this.prisma.category.create({
|
const category = await this.prisma.category.create({
|
||||||
data: {
|
data: {
|
||||||
name: dto.name,
|
name: dto.name,
|
||||||
|
image: dto.image,
|
||||||
restaurantId: dto.restaurantId,
|
restaurantId: dto.restaurantId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -81,9 +81,11 @@ export class ItemService {
|
|||||||
async remove(id: string, userId: string) {
|
async remove(id: string, userId: string) {
|
||||||
const item = await this.findOne(id);
|
const item = await this.findOne(id);
|
||||||
|
|
||||||
return await this.restaurantService.verifyOwnership(
|
await this.restaurantService.verifyOwnership(
|
||||||
userId,
|
userId,
|
||||||
item.restaurantId,
|
item.restaurantId,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return this.prisma.menuItem.delete({ where: { id } });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user