Advertisement
braveheart1989

Models

May 27th, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const mongoose = require('mongoose')
  2.  
  3. let commentSchema = new mongoose.Schema({
  4.   articleID: mongoose.Schema.ObjectId,
  5.   content: String,
  6.   date: { type: Date, default: Date.now() }
  7. })
  8. mongoose.model('Comment', commentSchema)
  9. //////////////////////////////////////////
  10.  
  11. const mongoose = require('mongoose')
  12.  
  13. let articleSchema = new mongoose.Schema({
  14.   title: String,
  15.   content: String,
  16.   image: String,
  17.   comments: [ { type: mongoose.Schema.Types.ObjectId, ref: 'Comment' } ]
  18. })
  19. mongoose.model('Article', articleSchema)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement