-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.js
More file actions
42 lines (35 loc) · 1 KB
/
db.js
File metadata and controls
42 lines (35 loc) · 1 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
const mongoose = require('mongoose');
require('dotenv').config();
mongoose.connect(process.env.MONGO_DB);
const { Schema } = mongoose;
const ObjectId = Schema.Types.ObjectId
const UserSchema = new Schema({
email : {type : String, unique : true},
password : String,
firstName : String,
LastName : String
});
const AdminSchema = new Schema({
email : {type : String, unique : true},
password : String,
firstName : String,
LastName : String
});
const CourseSchema = new Schema({
title : String,
description : String,
price : Number,
imageUrl : String,
creatorId : ObjectId
});
const PurchaseSchema = new Schema({
userId : ObjectId,
courseId : ObjectId
});
const usermodel = mongoose.model('user',UserSchema);
const adminmodel = mongoose.model('admin',AdminSchema);
const coursemodel = mongoose.model('course',CourseSchema);
const purchasemodel = mongoose.model('purchase',PurchaseSchema);
module.exports = {
usermodel , adminmodel, coursemodel, purchasemodel
}