上我有2個集合如何獲得集合名稱express.js服務器
appoinments
invoice
在我的崗位方法,保存數據之前,我檢查這些數據已經存在,但我只想要appoinments
集合。 我想正常保存invoice
收集。我怎樣才能做到這一點。我已經試過如果陳述,但它沒有奏效。
app.post('/collections/:collectionName', function(req, res, next) {
console.log(req.body[0])
if('/collections/:collectionName' == '/collections/appoinments'){
req.collection.findOne({hour_responce:req.body[0].hour_responce}, function(e, result){
if(result){
console.log(result); console.log(e)
res.send(500,{error:"You Already have a Task on this Time Period"})
}
else{
req.collection.insert(req.body, {}, function(e, results){
if (e) return next(e)
res.send(results)
})
}
})
}
else{
req.collection.insert(req.body, {}, function(e, results){
if (e) return next(e)
res.send(results)
})
}
})
'如果( '/收藏/:集合名' == '/收藏/ appoinments')'永遠比賽。嘗試'if(req.params.collectionName =='appointmentments')' – 2014-11-04 12:12:22
@ ben-fortune謝謝+1 – kosala 2014-11-05 07:51:03