forked from Tythla/TopFlush
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseed.js
111 lines (104 loc) · 2.51 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
111
const mongoose = require("mongoose");
const Restroom = require("./models/restrooms");
const Review = require("./models/reviews");
const User = require("./models/users");
async function seedDB() {
await Restroom.deleteMany({});
await Review.deleteMany({});
const initRestroom = [
{
location: {
address: "229 Washington St Public Restroom",
city: "Hoboken",
state: "NJ",
latitude: 40.739620,
longitude: -74.030000
},
capacity: 3,
rating: 4,
ratingMetrics: {
cleanliness: 4,
accessibility: 5,
facility: 3,
},
metrics: {
isOpen: true,
hasBabyChangingTable: true,
providesSanitaryProducts: true,
customerOnly: false,
dryer: true,
},
pathToImage: "/public/storage/229.jpeg",
},
{
location: {
address: "UCC University Towers Public Restroom",
city: "Hoboken",
state: "NJ",
latitude: 40.7441753,
longitude: -74.0245282,
},
capacity: 6,
rating: 5,
ratingMetrics: {
cleanliness: 5,
accessibility: 5,
facility: 5,
},
metrics: {
isOpen: true,
hasBabyChangingTable: false,
providesSanitaryProducts: true,
customerOnly: false,
dryer: true,
},
pathToImage: "/public/storage/ucc.jpeg",
},
{
location: {
address: "4901 Bergenline Ave Public Restroom",
city: "West New York",
state: "NJ",
latitude: 40.753500,
longitude: -74.041500
},
capacity: 3,
rating: 3,
ratingMetrics: {
cleanliness: 3,
accessibility: 3,
facility: 3,
},
metrics: {
isOpen: true,
hasBabyChangingTable: true,
providesSanitaryProducts: true,
customerOnly: true,
dryer: true,
},
pathToImage: "/public/storage/4901.jpeg",
},
];
const createdRestrooms = await Restroom.insertMany(initRestroom);
const randomUser = await User.findOne();
if (!randomUser) {
console.log("No users found in the database.");
return;
}
const initReviews = [
{
restroomId: createdRestrooms[1]._id,
userId: randomUser._id,
text: "Very clean",
rating: 5,
},
{
restroomId: createdRestrooms[1]._id,
userId: randomUser._id,
text: "Good enviroment, but limited space.",
rating: 4,
},
];
await Review.insertMany(initReviews);
}
module.exports = seedDB;