-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopulate_db.js
171 lines (152 loc) · 5.18 KB
/
populate_db.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
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
const mongoose = require('mongoose');
const db = require('./models/db.js'); // Require your Mongoose database configuration file
const Post = require('./models/PostModel.js'); // Require the Post model
const User = require('./models/UserModel.js');
const Comment = require('./models/CommentModel.js');
const url = 'mongodb+srv://noahhbernardo:[email protected]/hive';
mongoose.connect(url, {useNewUrlParser: true, useUnifiedTopology: true});
async function insertPosts() {
try {
const insertedPosts = await db.insertMany(Post, [
{
filename: '/user1_icon.jpg',
username: 'drinkwater',
title: 'A daily reminder to drink water',
content: 'Drinking water is a brilliant investment in your well-being, as it nourishes your body, fuels your mind, and replenishes your spirit, allowing you to flow through life with clarity, vitality, and utmost brilliance.',
commentcount: 1,
votes: 12456
},
{
filename: '/user2_icon.jpg',
username: 'PawsomePal',
title: 'Just dog things',
content: 'Does anyone else talk to their dog like they\'re a human? Asking for a friend... #DogConversations',
commentcount: 1,
votes: 654
},
{
filename: '/user3_icon.jpg',
username: 'TheCAGE',
title: 'Long live Nicolas Cage!',
content: 'Can we take a moment to appreciate Nicolas Cage\'s versatility as an actor? From intense dramas to hilarious comedies, he can do it all!',
commentcount: 1,
votes: 32
},
{
filename: '/user4_icon.jpg',
username: 'Busy_Beekeeper',
title: 'The Bee Transfer Chronicles',
content: 'Today, I stepped into the enchanting world of beekeeping by transferring a bee colony. With protective gear on and heart pounding, I witnessed the intricate choreography of bees, their fascinating communication, and the profound connection between beekeeper and colony. #BeekeepingAdventure',
commentcount: 1,
votes: 3
},
{
filename: '/user5_icon.jpg',
username: 'dave',
title: 'Wigo Roadtrip!',
content: 'Excited to announce that I\'ve just become the proud owner of a brand new Toyota Wigo! The perfect combination of style, efficiency, and reliability. Ready to hit the road and create unforgettable memories. #NewCarFeels #ToyotaWigo',
commentcount: 1,
votes: 35
}
]);
console.log('Posts inserted:', insertedPosts);
} catch (error) {
console.error('Error inserting posts:', error);
}
}
async function insertUsers() {
try {
const insertedUsers = await db.insertMany(User, [
{
username: 'drinkwater',
fname: 'drink',
lname: 'water',
email: '[email protected]',
pw: 'water',
dp: '/user1_icon.jpg',
},
{
username: 'PawsomePal',
fname: 'Pawsome',
lname: 'Pal',
email: '[email protected]',
pw: 'dog',
dp: '/user2_icon.jpg',
},
{
username: 'TheCAGE',
fname: 'Nicolas',
lname: 'Cage',
email: '[email protected]',
pw: 'cage',
dp: '/user3_icon.jpg',
},
{
username: 'Busy_Beekeeper',
fname: 'Busy',
lname: 'Beekeeper',
email: '[email protected]',
pw: 'bee',
dp: '/user4_icon.jpg',
},
{
username: 'dave',
fname: 'dave',
lname: 'dave',
email: '[email protected]',
pw: 'dave',
dp: '/user5_icon.jpg',
},
]);
console.log('Users inserted:', insertedUsers);
} catch (error) {
console.error('Error inserting users:', error);
}
}
async function insertComments(){
try {
const insertedComments = await db.insertMany(Comment, [
{
filename: '/user2_icon.jpg',
username: 'PawsomePal',
parentid: '64ce069b19c2dad7ba854f31',
content: 'I agree!',
commentcount: 0
},
{
filename: '/user3_icon.jpg',
username: 'TheCAGE',
parentid: '64ce069b19c2dad7ba854f32',
content: 'Dogs are the best',
commentcount: 0
},
{
filename: '/user1_icon.jpg',
username: 'drinkwater',
parentid: '64ce069b19c2dad7ba854f33',
content: 'Loved his performance in Ghost Rider',
commentcount: 0
},
{
filename: '/user5_icon.jpg',
username: 'dave',
parentid: '64ce069b19c2dad7ba854f34',
content: 'Congrats!',
commentcount: 0
},
{
filename: '/user4_icon.jpg',
username: 'Busy_Beekeper',
parentid: '64ce069b19c2dad7ba854f35',
content: 'A bee sticker would make a nice accessory! Want one?',
commentcount: 0
},
]);
console.log('Comments inserted:', insertedComments);
} catch (error) {
console.error('Error inserting Comments:', error);
}
}
//insertPosts(); //Do not use this anymore
//insertUsers();
//insertComments();