1
我檢查我的分貝形成終端和數據是好的,但是當填入「commnets」還是給我的ID架構和模式都OK和貓鼬.populate不工作
這是我的路線,以顯示數據
var camp_id= req.params.id ;
Campground.findById(camp_id).populate("commnets").exec(function(err,fcg){
if(err) { console.log(err) ;}
else {
console.log("No err") ;
console.log(fcg) ;
res.render("show",{campground: fcg});}
}) ;
moongose模式(營地和評論)
var campgroundSchema = new mongoose.Schema({
name: String ,
image: String ,
description : String ,
comments: [
{
type: mongoose.Schema.Types.ObjectId,
ref: "Commnet"
}
]
}) ;
var Campground = mongoose.model("Campground",campgroundSchema);
var commentSchema = new mongoose.Schema({
text: String ,
aurthor: String
}) ;
var Comment = mongoose.model("Commnet",commentSchema) ;
嗯,這是令人尷尬的「評論」:P 我浪費了太多的時間在這 非常感謝^ _ ^ –