-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.js
67 lines (57 loc) · 1.75 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
var mongoose = require('mongoose');
var localPassport = require('passport-local-mongoose');
//add email - username, password and salt already added
var User = new mongoose.Schema({});
User.plugin(localPassport);
//install plugin
var Movie = new mongoose.Schema({
title:String,
year:String,
rating: Number,
genre: String,
director:String,
poster_url: String
});
var Show = new mongoose.Schema({
title:String,
year:String,
rating: Number,
genre: String,
poster_url: String
});
var Statistic = new mongoose.Schema({
username:String, total: Number, movies: Number,
shows: Number, documentary: Number, action: Number,
drama: Number, adventure: Number, animation: Number,
comedy: Number, crime: Number,family: Number,
kids: Number, fantasy: Number, history: Number, horror: Number,
mystery: Number, sci_fi: Number, thriller: Number, war: Number,
western: Number, reality: Number, news: Number
});
var Profile = new mongoose.Schema({
first_name:{type:String, required: [true, 'Firstname is required']},
last_name: {type:String, required: [true, 'Lastname is required']},
username: {type:String, required: [true, 'Username is required']},
age: {type:Number, required: [true, 'Age is required']},
movies:[Movie],
shows:[Show]
});
var MovieGenre = new mongoose.Schema({
id: Number,
name:String,
pages:Number
});
var TVGenre = new mongoose.Schema({
id: Number,
name:String,
pages:Number
});
//registering models
mongoose.model('Movie', Movie);
mongoose.model('Show', Show);
mongoose.model('User', User);
mongoose.model('Statistic', Statistic);
mongoose.model('Profile', Profile);
mongoose.model('MovieGenre', MovieGenre);
mongoose.model('TVGenre', TVGenre);
mongoose.connect('mongodb://localhost/moviedb');