-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.js
More file actions
60 lines (53 loc) · 1.58 KB
/
models.js
File metadata and controls
60 lines (53 loc) · 1.58 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
49
50
51
52
53
54
55
56
57
58
59
60
const mongoose = require('mongoose');
var url = "mongodb+srv://admin:b6AZoa2pNI6rZ2fJ@cluster0.wy392.mongodb.net/Movies?authSource=admin&replicaSet=atlas-ka4ujp-shard-0&readPreference=primary&appname=MongoDB%20Compass&ssl=true"
mongoose.connect(url,{useNewUrlParser:true, useUnifiedTopology:true, useFindAndModify: false, useCreateIndex: true }, (err)=>{
if(!err){
console.log("Database connected...");
}else{
console.log("Error in connecting to Database");
}
});
const { Schema, model, Types } = require('mongoose')
var MovieSchema = new Schema({
details: {
type: {
title: { type: String },
seeds: { type: Number },
peers: { type: Number },
size: { type: String },
desc: { type: String },
time: { type: String },
link: { type: String },
image: { type: String },
subtitle: { type: String }
}
},
hashes: {
type: [
{
lang: { type: String },
hash: { type: String }
}
]
}
});
model('movie', MovieSchema);
var SeriesSchema = new Schema({
name: { type: String },
seasons: {
type: [
{
episodes: {
type: [
{
name: { type: String },
hash: { type: String },
file: { type: Number }
}
]
}
}
]
}
});
model('series', SeriesSchema);