-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlaylist.js
56 lines (51 loc) · 1.2 KB
/
Playlist.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
const mongoose = require('mongoose');
const {
Schema,
Types: { ObjectId }
} = mongoose;
const LinkSchema = require('./Link').schema;
const PlaylistSchema = new Schema({
_user: {
type: ObjectId,
ref: 'User'
},
name: {
type: String,
trim: true,
required: [true, 'First name is required']
},
links: {
type: [LinkSchema]
},
totalLinks: {
type: Number,
required: [true, 'Number of links is required']
},
privacy: {
type: String,
enum: ['public', 'private'],
default: 'private'
},
created: {
type: Date,
default: Date.now
},
updated: {
type: Date,
default: Date.now
}
});
// UserSchema.static('findByEmail', async function (email) {
// return await this.findOne({ email });
// });
// UserSchema.pre('save', function (next) {
// this.updated = Date.now();
// return next;
// });
// UserSchema.method('verifyPassword', function (password) {
// return new Promise(async resolve => {
// const passwordIsCorrect = await bcrypt.compare(password, this.password);
// resolve(passwordIsCorrect);
// });
// });
module.exports = mongoose.model('Playlist', PlaylistSchema);