Skip to content

Instantly share code, notes, and snippets.

@desaijay315
Created April 5, 2019 03:24
Show Gist options
  • Save desaijay315/188d860bc00f96dd12ae47d44bb8e47f to your computer and use it in GitHub Desktop.
Save desaijay315/188d860bc00f96dd12ae47d44bb8e47f to your computer and use it in GitHub Desktop.
const mongoose = require('mongoose');
const PostSchema = new mongoose.Schema({
title:{
type:String,
unique:true,
required: true,
trim: true
},
description:{
type: String,
required:true,
trim: true
},
author:{
type: mongoose.Schema.Types.ObjectId,
required:true,
ref:'User'
},
createdAt:{
type: Date,
default: Date.now
}
});
const Post = mongoose.model('Post', PostSchema);
module.exports = Post
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment