-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseedDatabase.js
More file actions
208 lines (198 loc) · 4.76 KB
/
seedDatabase.js
File metadata and controls
208 lines (198 loc) · 4.76 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
const mongoose = require("mongoose");
require("dotenv").config();
// Import models
const FunctionalGroup = require("./models/functionalGroup");
const AminoAcid = require("./models/aminoAcid");
// Sample data for Functional Groups
const functionalGroupsData = [
{
name: "Alcohol",
use: "Found in beverages, solvents, and antiseptics",
example: "Ethanol (C₂H₅OH)"
},
{
name: "Aldehyde",
use: "Used in perfumes, flavoring agents, and preservatives",
example: "Formaldehyde (HCHO)"
},
{
name: "Ketone",
use: "Used as solvents and in polymer production",
example: "Acetone (CH₃COCH₃)"
},
{
name: "Carboxylic_acid",
use: "Found in vinegar, citrus fruits, and used in food preservation",
example: "Acetic acid (CH₃COOH)"
},
{
name: "Ester",
use: "Used in fragrances, flavoring, and plastics",
example: "Ethyl acetate (CH₃COOC₂H₅)"
},
{
name: "Amine",
use: "Found in amino acids, proteins, and pharmaceuticals",
example: "Methylamine (CH₃NH₂)"
},
{
name: "Amide",
use: "Found in proteins and used in pharmaceuticals",
example: "Acetamide (CH₃CONH₂)"
},
{
name: "Ether",
use: "Used as solvents and anesthetics",
example: "Diethyl ether (C₂H₅OC₂H₅)"
}
];
// Sample data for Amino Acids
const aminoAcidsData = [
{
name: "Alanine",
symbol: "Ala",
code: "A",
group: "Nonpolar, aliphatic"
},
{
name: "Glycine",
symbol: "Gly",
code: "G",
group: "Nonpolar, aliphatic"
},
{
name: "Valine",
symbol: "Val",
code: "V",
group: "Nonpolar, aliphatic"
},
{
name: "Leucine",
symbol: "Leu",
code: "L",
group: "Nonpolar, aliphatic"
},
{
name: "Isoleucine",
symbol: "Ile",
code: "I",
group: "Nonpolar, aliphatic"
},
{
name: "Methionine",
symbol: "Met",
code: "M",
group: "Nonpolar, aliphatic"
},
{
name: "Phenylalanine",
symbol: "Phe",
code: "F",
group: "Aromatic"
},
{
name: "Tryptophan",
symbol: "Trp",
code: "W",
group: "Aromatic"
},
{
name: "Tyrosine",
symbol: "Tyr",
code: "Y",
group: "Aromatic"
},
{
name: "Serine",
symbol: "Ser",
code: "S",
group: "Polar, uncharged"
},
{
name: "Threonine",
symbol: "Thr",
code: "T",
group: "Polar, uncharged"
},
{
name: "Cysteine",
symbol: "Cys",
code: "C",
group: "Polar, uncharged"
},
{
name: "Asparagine",
symbol: "Asn",
code: "N",
group: "Polar, uncharged"
},
{
name: "Glutamine",
symbol: "Gln",
code: "Q",
group: "Polar, uncharged"
},
{
name: "Lysine",
symbol: "Lys",
code: "K",
group: "Positively charged"
},
{
name: "Arginine",
symbol: "Arg",
code: "R",
group: "Positively charged"
},
{
name: "Histidine",
symbol: "His",
code: "H",
group: "Positively charged"
},
{
name: "Aspartate",
symbol: "Asp",
code: "D",
group: "Negatively charged"
},
{
name: "Glutamate",
symbol: "Glu",
code: "E",
group: "Negatively charged"
},
{
name: "Proline",
symbol: "Pro",
code: "P",
group: "Cyclic"
}
];
async function seedDatabase() {
try {
// Connect to MongoDB
await mongoose.connect(process.env.DB_CONNECTION, {
useUnifiedTopology: true,
useNewUrlParser: true,
});
console.log("✅ Connected to MongoDB Atlas");
// Clear existing data
await FunctionalGroup.deleteMany({});
await AminoAcid.deleteMany({});
console.log("🗑️ Cleared existing data");
// Insert functional groups
await FunctionalGroup.insertMany(functionalGroupsData);
console.log(`✅ Added ${functionalGroupsData.length} functional groups`);
// Insert amino acids
await AminoAcid.insertMany(aminoAcidsData);
console.log(`✅ Added ${aminoAcidsData.length} amino acids`);
console.log("\n🎉 Database seeded successfully!");
console.log("\nYou can now use the flashcard app with real data!");
process.exit(0);
} catch (error) {
console.error("❌ Error seeding database:", error);
process.exit(1);
}
}
seedDatabase();