Skip to content

Commit

Permalink
シードで Pair も作成する
Browse files Browse the repository at this point in the history
  • Loading branch information
k-kbot committed Aug 27, 2023
1 parent 8db9a28 commit 04b8358
Showing 1 changed file with 54 additions and 4 deletions.
58 changes: 54 additions & 4 deletions backend/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,80 @@ import { PrismaClient, Prisma } from '@prisma/client';

const prisma = new PrismaClient();

const teamData: Prisma.TeamCreateInput[] = [
const teams: Prisma.TeamCreateInput[] = [
{
id: '1',
name: '001',
pairs: {
create: [
{
id: '1',
name: 'a',
},
{
id: '2',
name: 'b',
},
],
},
},
{
id: '2',
name: '002',
pairs: {
create: [
{
id: '3',
name: 'a',
},
{
id: '4',
name: 'b',
},
],
},
},
{
id: '3',
name: '003',
pairs: {
create: [
{
id: '5',
name: 'a',
},
{
id: '6',
name: 'b',
},
],
},
},
{
id: '4',
name: '004',
pairs: {
create: [
{
id: '7',
name: 'a',
},
{
id: '8',
name: 'b',
},
],
},
},
];

async function main() {
console.log(`Start seeding ...`);
for (const u of teamData) {
const team = await prisma.team.create({
data: u,
for (const u of teams) {
const team = await prisma.team.upsert({
where: { id: u.id },
update: {},
create: u,
});
console.log(`Created user with id: ${team.id}`);
}
Expand Down

0 comments on commit 04b8358

Please sign in to comment.