aboutsummaryrefslogtreecommitdiff
path: root/models/post.js
diff options
context:
space:
mode:
Diffstat (limited to 'models/post.js')
-rw-r--r--models/post.js16
1 files changed, 13 insertions, 3 deletions
diff --git a/models/post.js b/models/post.js
index 8227c85..f01431b 100644
--- a/models/post.js
+++ b/models/post.js
@@ -1,9 +1,19 @@
const mongoose = require('mongoose');
const postSchema = new mongoose.Schema({
- title: {type: String, required: true},
- text: {type: String, required: true},
- date: {type: Date, default: Date.now}
+ title: {
+ type: String,
+ required: [true, "You need to provide a title."],
+ maxLength: [100, "You can't have a title more than 100 characters long."]
+ },
+ text: {
+ type: String,
+ required: [true, "You need to provide some text."]
+ },
+ date: {
+ type: Date,
+ default: Date.now
+ }
});
const postModel = mongoose.model('post', postSchema);