-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseed.ts
79 lines (70 loc) · 2.12 KB
/
seed.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// import { db } from '@/db/db'
// import { attendees, events, rsvps } from '@/db/schema'
// const seedDatabase = async () => {
// try {
// const newUser = await db.query.users.findFirst()
// if (!newUser) {
// console.error('create an account first')
// return
// }
// const newEvents = await db
// .insert(events)
// .values([
// {
// name: 'Tech Conference 2021',
// startOn: '2024-09-10',
// createdById: newUser.id,
// description: 'A conference about the latest in tech.',
// streetNumber: 123,
// street: 'Innovation Blvd',
// zip: 94043,
// bldg: '12A',
// isPrivate: false,
// status: 'live',
// },
// {
// name: 'Music Festival 2021',
// startOn: '2024-10-05',
// createdById: newUser.id,
// description: 'Enjoy music from top artists from around the world.',
// streetNumber: 456,
// street: 'Festival Road',
// zip: 94043,
// bldg: '9B',
// isPrivate: true,
// status: 'draft',
// },
// ])
// .returning()
// // Adding attendees
// const newAttendees = await db
// .insert(attendees)
// .values([
// {
// email: '[email protected]',
// name: 'Jesse Doe',
// },
// {
// email: '[email protected]',
// name: 'Alice Wonderland',
// },
// ])
// .returning()
// console.log('Attendees added:', newAttendees.length)
// // Adding RSVPs for each attendee to each event
// const data = newAttendees
// .map((attendee) =>
// newEvents.map((event) => ({
// attendeeId: attendee.id,
// eventId: event.id,
// status: 'going',
// }))
// )
// .flat()
// const newRSVPs = await db.insert(rsvps).values(data).returning()
// console.log('created rsvps ', newRSVPs.length)
// } catch (error) {
// console.error('Failed to seed database:', error)
// }
// }
// seedDatabase()