Skip to content

Commit

Permalink
feat: add id in shown fields
Browse files Browse the repository at this point in the history
  • Loading branch information
nhan committed Jun 11, 2023
1 parent 5e126bb commit 976b370
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ function getRandomInt(min: number, max: number): number {
}

function makeEmail(length: number): string {
let result: string = '';
const characters: string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let result = '';
const characters =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const charactersLength: number = characters.length;
let counter: number = 0;
let counter = 0;

while (counter < length) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
counter += 1;
}
return result + "@gmail.com";
return result + '@gmail.com';
}

async function main() {
Expand Down Expand Up @@ -78,6 +79,7 @@ async function main() {
const speaks: string[] = ['Flexing', 'Vietnamese', 'English'];

const introShownFields = {
id: true,
yearOfBirth: true,
bodyType: true,
diet: true,
Expand Down Expand Up @@ -131,7 +133,7 @@ async function main() {
smokes: randomChoice(smokes),
speaks: randomChoice(speaks),
introShownFields: introShownFields,
}
},
});
});

Expand Down Expand Up @@ -168,26 +170,26 @@ async function main() {
smokes: randomChoice(smokes),
speaks: randomChoice(speaks),
introShownFields: introShownFields,
}
},
});
});

await new Promise(r => setTimeout(r, 2000));
await new Promise((r) => setTimeout(r, 2000));

await prisma.notification.create({
data: {
text: 'Congrats, you are the admin',
status: 'UNREAD',
userId: 1,
}
},
});

await prisma.coupon.create({
data: {
code: 'DAKWA',
discountPercent: 100,
userId: 1,
}
},
});

await prisma.report.create({
Expand All @@ -197,24 +199,24 @@ async function main() {
reporterName: 'psycholog1st',
targetName: 'chovbeovkieu',
status: 'PENDING',
}
},
});

await prisma.user_image.create({
data: {
url: "https://cc.com/image123",
url: 'https://cc.com/image123',
isThumbnail: true,
userId: 1,
}
},
});
}

main()
.then(async () => {
await prisma.$disconnect()
await prisma.$disconnect();
})
.catch(async (e) => {
console.error(e)
await prisma.$disconnect()
process.exit(1)
console.error(e);
await prisma.$disconnect();
process.exit(1);
});

0 comments on commit 976b370

Please sign in to comment.