Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const mongoose = require('mongoose')
- let commentSchema = new mongoose.Schema({
- articleID: mongoose.Schema.ObjectId,
- content: String,
- date: { type: Date, default: Date.now() }
- })
- mongoose.model('Comment', commentSchema)
- //////////////////////////////////////////
- const mongoose = require('mongoose')
- let articleSchema = new mongoose.Schema({
- title: String,
- content: String,
- image: String,
- comments: [ { type: mongoose.Schema.Types.ObjectId, ref: 'Comment' } ]
- })
- mongoose.model('Article', articleSchema)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement