-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseed.js
110 lines (101 loc) · 3.02 KB
/
seed.js
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
const db = require("./database");
// Insert sample companies
const companies = [
{ CompanyName: "Express Home Labs and IV", WebsiteLink: null, Email: null },
{ CompanyName: "Velvet Effect Electrolysis", WebsiteLink: null, Email: null },
{
CompanyName: "Community Leasing",
WebsiteLink: null,
Email: "[email protected]",
},
];
companies.forEach((company) => {
db.run(
`INSERT OR IGNORE INTO Companies (CompanyName, WebsiteLink, Email) VALUES (?, ?, ?)`,
[company.CompanyName, company.WebsiteLink, company.Email],
(err) => {
if (err) console.error(err.message);
}
);
});
// Insert sample locations
const locations = [
{ CompanyID: 1, Address: "Not specified", Phone: "347-723-7707" },
{ CompanyID: 2, Address: "Bates Area", Phone: "845-803-0142" },
];
locations.forEach((location) => {
db.run(
`INSERT OR IGNORE INTO CompanyLocations (CompanyID, Address, Phone) VALUES (?, ?, ?)`,
[location.CompanyID, location.Address, location.Phone],
(err) => {
if (err) console.error(err.message);
}
);
});
// Insert sample sale events
const saleEvents = [
{
Title: "Black Friday Sale",
Description: "Huge discounts on all products!",
SaleType: "Retail Sale",
Category: "Shopping",
DiscountPercentage: "50%",
SpecialPromotions: "Buy one, get one free",
EventDate: "2024-11-29",
EventTime: "08:00 AM",
Location: "Main Street",
ContactInfo: "[email protected]",
},
];
saleEvents.forEach((event) => {
db.run(
`INSERT OR IGNORE INTO SaleEvents (Title, Description, SaleType, Category, DiscountPercentage, SpecialPromotions, EventDate, EventTime, Location, ContactInfo) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
[
event.Title,
event.Description,
event.SaleType,
event.Category,
event.DiscountPercentage,
event.SpecialPromotions,
event.EventDate,
event.EventTime,
event.Location,
event.ContactInfo,
],
(err) => {
if (err) console.error(err.message);
}
);
});
// Insert sample event details
const eventDetails = [
{
EventIDSubquery:
"SELECT EventID FROM SaleEvents WHERE Title = 'Black Friday Sale'",
Organizer: "Chany Felberbaum",
EventFormat: "Virtual Summit",
RegistrationLink: "http://www.chanyfelberbaum.com/summit",
ContactInfo:
"[email protected] | Text register to 646-979-0710",
Speakers: "Dina Friedman, Shterna Ginsberg, ...",
TopicsCovered: "IFS, EFT, Breathwork, ...",
},
];
eventDetails.forEach((detail) => {
db.run(
`INSERT OR IGNORE INTO EventDetails (EventID, Organizer, EventFormat, RegistrationLink, ContactInfo, Speakers, TopicsCovered)
VALUES ((${detail.EventIDSubquery}), ?, ?, ?, ?, ?, ?)`,
[
detail.Organizer,
detail.EventFormat,
detail.RegistrationLink,
detail.ContactInfo,
detail.Speakers,
detail.TopicsCovered,
],
(err) => {
if (err) console.error("EventDetails error:", err.message);
}
);
});
console.log("Data inserted!");