Если кто-нибудь может мне помочь.Я хочу сделать следующее. С помощью флажка я хочу выбрать, какое сообщение поместить на главную страницу
Это моя схема
var foodSchema = new mongoose.Schema({
title:String,
image:String,
text:String,
video:String,
checkBox:{type:Boolean, default:false},
created:{type: Date, default:Date.now},
comments:[{
type: mongoose.Schema.Types.ObjectId,
ref:"comment"
}
]
});
Это мой новый файл .ejs
<spam class="hederSpam">
<input type="checkbox" name="checked" value="true">
post
</spam>
```
here i wanna to display
``` <%newFood.forEach(function(check){ %>
<%if(check.checkBox===true){%>
<h3 class="indexh2"><%= check.title %></h3>
<%= check.checkBox%>
<a href="/food/<%= check._id%> " >Read More</a>
<% })%>
и в файле site.js я пытаюсь это сделать, но каждый раз выдает мне ложь ..
food.create(req.body.foodForm, function(err, postFood){
var n = req.body.checked;
if(err){
console.log("err")
}else{
if( n == "true"){
food.checkBox=true;
}
res.redirect("/food");
}
})
});