forked from Bitbox-Connect/Bitbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblog.js
45 lines (42 loc) · 925 Bytes
/
blog.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
const mongoose = require('mongoose');
const blogSchema = new mongoose.Schema({
title: {
type: String,
required: true,
trim: true,
minlength: 5
},
author: {
type: String,
required: true,
trim: true
},
date: {
type: Date,
default: Date.now
},
content: {
type: String,
required: true,
minlength: 50
},
category: {
type: String,
required: true,
trim: true,
enum: ["Tech", "Health", "Finance"] // Example categories
},
tags: {
type: [String],
default: []
},
comments: [
{
user: { type: String, required: true },
comment: { type: String, required: true },
date: { type: Date, default: Date.now }
}
]
});
const Blog = mongoose.model('Blog', blogSchema);
module.exports = Blog;