-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblog.model.js
42 lines (38 loc) · 855 Bytes
/
blog.model.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
import mongoose from "mongoose";
const blogSchema = new mongoose.Schema({
title : {
type: String,
require: true,
trim: true,
min: 3,
},
body: {
type: {},
require: true,
trim: true,
max: 2000000,
},
slug: {
type: String,
unique: true,
index: true,
},
mtitle: {
type: String,
},
mdesc: {
type: {},
},
photo : {
data: Buffer,
contentType: String,
},
catagories: [{type: mongoose.Schema.ObjectId, ref: 'Category', required: true}],
tags: [{type: mongoose.Schema.ObjectId, ref: 'Tag', required: true}],
postedBy: {type: mongoose.Schema.ObjectId,ref: 'User', required: true},
},
{
timeStamps : true,
}
)
module.exports = mongoose.model('Blog', blogSchema)