我正在将网页数据插入Mongo DB数据库,使用的是Node JS + Express + Jade。
我需要根据复选框是否被选中来插入True或False。
在我的router.js文件中,我有以下代码:
app.get('/notification', function(req, res) {
res.render('notification', { title: 'Nueva notificacion', notifications : NT });
});
app.post('/notification', function(req, res){
console.log('Adding new notification');
AM.addNewNotification({
name : req.param('name'),
notification : req.param('notification'),
active : req.param('active')
}, function(e){
if (e){
res.send(e, 400);
} else{
res.send('ok', 200);
}
});
});
在我的看法中,我有以下观点:
.controls
label#active-me.checkbox Active
input(type="checkbox", name="active", id="active",checked='checked')
但是我无法插入它,似乎值没有被接受。 只有名称和通知值(文本)被插入。
{ "name" : "Goodbye world", "notification" : "Short Message Service", "_id" : ObjectId("5298f603bd07b80376000005") }
任何建议吗?
谢谢。