如何使用特定id发布mongoose模型的评论
我创建了两个猫鼬模型:如何使用特定id发布mongoose模型的评论,mongoose,ejs,Mongoose,Ejs,我创建了两个猫鼬模型: var Post = new Schema({ name: String, description: String, address: String, comments: [{ type: Schema.Types.ObjectId, ref: 'Comment' }], phoneNum: { type: Number, unique: true } }); module.exports = mongoose.model("Post", Pos
var Post = new Schema({
name: String,
description: String,
address: String,
comments: [{ type: Schema.Types.ObjectId, ref: 'Comment' }],
phoneNum: { type: Number,
unique: true }
});
module.exports = mongoose.model("Post", Post);
var Comment = new Schema({
comments: { type: String }
});
module.exports = mongoose.model("Comment", Comment);
我试图弄清楚如何通过Id发布特定post文档的注释,以及如何在ejs视图中呈现此文档的注释。我真的很感激任何帮助