-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
42 lines (41 loc) · 929 Bytes
/
content.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
const mongoose = require('mongoose')
const Schema = mongoose.Schema
let Content = new Schema(
{
uploader: {
type: Schema.Types.ObjectId,
ref: 'Users',
},
title: {
type: String,
required:false,
},
subTitle : {
type: String,
required:false,
},
desc : {
type: String,
required:false,
},
owner: {
type: String,
required:false,
},
reference: {
type: String,
required: false,
},
},
{
timestamps: true,
}
)
// hide some attributes of Post model while sending json response
Content.methods.toJSON = function () {
let content = this.toObject()
delete content.updatedAt
delete content.__v
return content
}
module.exports = mongoose.model('Content', Content)