fix
Desc: - Penambahan seeder bidang bisnis
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import prisma from "@/app/lib/prisma";
|
import prisma from "@/app/lib/prisma";
|
||||||
import userRole from "../../../bin/seeder/user_role.json";
|
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
import userRole from "../../../bin/seeder/user_role.json";
|
||||||
|
import bidangBisnis from "../../../bin/seeder/bidang_bisnis.json";
|
||||||
|
|
||||||
export async function GET(req: Request) {
|
export async function GET(req: Request) {
|
||||||
const dev = new URL(req.url).searchParams.get("dev");
|
const dev = new URL(req.url).searchParams.get("dev");
|
||||||
@@ -20,8 +21,24 @@ export async function GET(req: Request) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (let i of bidangBisnis) {
|
||||||
|
await prisma.masterBidangBisnis.upsert({
|
||||||
|
where: {
|
||||||
|
id: i.id.toString(),
|
||||||
|
},
|
||||||
|
update: {
|
||||||
|
id: i.id.toString(),
|
||||||
|
name: i.name,
|
||||||
|
},
|
||||||
|
create: {
|
||||||
|
id: i.id.toString(),
|
||||||
|
name: i.name,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
return NextResponse.json({ success: true });
|
return NextResponse.json({ success: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
return NextResponse.json({ success: false });
|
return NextResponse.json({ success: false });
|
||||||
}
|
}
|
||||||
|
|||||||
18
src/bin/seeder/bidang_bisnis.json
Normal file
18
src/bin/seeder/bidang_bisnis.json
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"name": "Software Developer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"name": "Makanan & Minuman"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"name": "Kosmetik"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4,
|
||||||
|
"name": "Mesin Mobil"
|
||||||
|
}
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user