송민석

Make DB Shcema

Showing 1 changed file with 24 additions and 4 deletions
1 const config =require('./config') 1 const config =require('./config')
2 const mongoose = require("mongoose"); 2 const mongoose = require("mongoose");
3 -const connect = mongoose 3 +const connect = mongoose.connect(config.url,
4 - .connect(config.url, { 4 + {
5 useNewUrlParser: true, 5 useNewUrlParser: true,
6 useUnifiedTopology: true, 6 useUnifiedTopology: true,
7 }) 7 })
8 - .then(() => console.log("MongoDB Connected ..."))
9 - .catch((err) => console.log(err));
...\ No newline at end of file ...\ No newline at end of file
8 + .then(() => console.log("DB : Succesfully Connected"))
9 + .catch((err) => console.log(err.message));
10 +
11 +
12 + const TimeSchema = new mongoose.Schema({
13 + time: String,
14 + prof: String,
15 + credit: Number,
16 + });
17 +
18 + const SubSchema = new mongoose.Schema({
19 + campus: String,
20 + college: String,
21 + department: String,
22 + grade: String,
23 + subject: [TimeSchema],
24 + });
25 +
26 + const Timeinfo = mongoose.model('Timeinfo', TimeSchema);
27 + const Subinfo = mongoose.model('Subinfo', SubSchema);
28 +
29 + module.exports = {Timeinfo, Subinfo};
......