-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.js
46 lines (36 loc) · 1.03 KB
/
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
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const ObjectId = mongoose.ObjectId;
const Users = new Schema({
fullname: String,
username: {type:String , unique:true},
email: {type:String , unique:true},
password: String
});
const Admins = new Schema({
fullname: String,
username: {type:String , unique:true},
email: {type:String , unique:true},
password: String
});
const Courses = new Schema({
title: String,
description: String,
price: Number,
thumbnail: String,
adminId: ObjectId
})
const Purchases = new Schema({
userId: ObjectId, // This user Bought :
courseId: ObjectId // THIS COURSE!
})
const UserModel = mongoose.model("users" , Users);
const AdminModel = mongoose.model("admins" , Admins);
const CourseModel = mongoose.model("courses" , Courses);
const PurchaseModel = mongoose.model("purchases" , Purchases);
module.exports = {
UserModel: UserModel,
AdminModel: AdminModel,
CourseModel: CourseModel,
PurchaseModel: PurchaseModel
}