Something went wrong. Try again.
VueTube is a YouTube clone built with nodejs, expressjs & mongodb. This is the RESTful API repository.
Something went wrong. Try again.
732 B · 33 lines
JavaScript
at master
12345678910111213141516171819202122232425262728293031323334const mongoose = require('mongoose')
const Schema = mongoose.Schema
const ReplySchema = new Schema( { text: { type: String, minlength: [3, 'Must be three characters long'], required: [true, 'Text is required'] }, commentId: { type: mongoose.Schema.ObjectId, ref: 'Comment', required: true }, userId: { type: mongoose.Schema.ObjectId, ref: 'User', required: true } }, { toJSON: { virtuals: true }, toObject: { virtuals: true }, timestamps: true })ReplySchema.pre('find', function () { this.populate({ path: 'userId', select: 'channelName photoUrl', sort: '+createdAt' })})
module.exports = mongoose.model('Reply', ReplySchema)