Skip to content

Commit

Permalink
feat: set default option true at seed
Browse files Browse the repository at this point in the history
  • Loading branch information
raipen committed Nov 24, 2023
1 parent 0bb6ea2 commit e74be47
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
51 changes: 51 additions & 0 deletions seeding/testSeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,50 @@ export default async (prisma: PrismaClient, storeId: number) => {
storeId
}
});

await prisma.option.createMany({
data: [
{
optionName: 'ice',
optionPrice: 0,
optionCategory: '온도',
},
{
optionName: 'hot',
optionPrice: 0,
optionCategory: '온도',
},
{
optionName: '원두1',
optionPrice: 0,
optionCategory: '원두',
},
{
optionName: '원두2',
optionPrice: 300,
optionCategory: '원두',
},
{
optionName: '1샷 추가',
optionPrice: 500,
optionCategory: '샷',
},
{
optionName: '샷 빼기',
optionPrice: 0,
optionCategory: '샷',
},
].map((option) => ({
...option,
storeId,
})),
});
const options = await prisma.option.findMany({
where: {
storeId
}
});

await prisma.menu.createMany({
data: menuDataWithMaterials.map((menu,index) => ({
name: menu.name,
Expand All @@ -214,6 +258,13 @@ export default async (prisma: PrismaClient, storeId: number) => {
}
});

await prisma.optionMenu.createMany({
data: menus.flatMap((menu) => options.map((option) => ({
menuId: menu.id,
optionId: option.id
})))
});

await prisma.recipe.createMany({
data: menuDataWithMaterials.flatMap((menu) => menu.materials.map((material) => ({
coldRegularAmount: material.coldRegularAmount,
Expand Down
1 change: 0 additions & 1 deletion src/api/routes/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const api: FastifyPluginAsync = async (server: FastifyInstance) => {
},
async (request, reply) => {
const result = await storeService.newStore(request.body);
await storeService.registDefaultOption(result);
await storeService.seeding(result);
reply.code(200).send(result);
}
Expand Down

0 comments on commit e74be47

Please sign in to comment.