40 lines
881 B
TypeScript
40 lines
881 B
TypeScript
import { PrismaClient } from '@prisma/client';
|
|
import { format, parseISO } from 'date-fns';
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function event() {
|
|
for (let i = 0; i < 5; i++) {
|
|
const helloworldEvent = await prisma.event.upsert({
|
|
where: { id: i },
|
|
update: {},
|
|
create: {
|
|
eventDate: new Date(),
|
|
joinMembers: undefined,
|
|
title: 'event ' + i,
|
|
price: 123 + i,
|
|
currency: 'HKD',
|
|
duration_m: 480 - i,
|
|
ageBottom: 12 + i,
|
|
ageTop: 48 - i,
|
|
location: 'Hong Kong Island',
|
|
avatar: 'https://www.ionics.io/img/ionic-logo.png'
|
|
}
|
|
});
|
|
}
|
|
|
|
console.log('seed event done');
|
|
}
|
|
|
|
const Event = event()
|
|
.then(async () => {
|
|
await prisma.$disconnect();
|
|
})
|
|
.catch(async (e) => {
|
|
console.error(e);
|
|
await prisma.$disconnect();
|
|
process.exit(1);
|
|
});
|
|
|
|
export { Event };
|