forked from info441-sp25/final-project-441
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.js
More file actions
48 lines (40 loc) · 1.27 KB
/
models.js
File metadata and controls
48 lines (40 loc) · 1.27 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
import mongoose from 'mongoose'
const models = {} // dictionary of all the models
console.log("connecting to mongodb")
// name of db -> web-sharer-a3
await mongoose.connect('mongodb+srv://laurak11:INFO441password@cluster0.e6e59z1.mongodb.net/!graduated?retryWrites=true&w=majority&appName=Cluster0')
console.log("successfully conected to mongodb")
const classSchema = new mongoose.Schema({
courseId: String, // full course name eg 'INFO441', no spaces
courseNumber: String,
courseTitle: String,
avgRating: Number,
courseCollege: String, //engineering, info, etc.
credits: String,
description: String,
genEdReqs: [String],
tags: [String],
reviews: [String]
})
const userSchema = new mongoose.Schema({
username: String,
username: String,
major: String,
biography: String,
profileImageUrl: String,
savedCourses: [String],
coursesTaken: [String],
reviews: [String]
})
const reviewSchema = new mongoose.Schema({
numStars: Number,
comment: String,
user: String,
courseId: String
})
// model
models.Class = mongoose.model('Class', classSchema)
models.User = mongoose.model('User', userSchema)
models.Review = mongoose.model('Review', reviewSchema)
console.log("finished creating models")
export default models