aboutsummaryrefslogblamecommitdiff
path: root/models/post.js
blob: f01431b1336bf81b00313f9ef1d547d80a2446bd (plain) (tree)
1
2
3


                                        












                                                                             




                                                     
const mongoose = require('mongoose');

const postSchema = new mongoose.Schema({
  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);

module.exports = postModel;