簡體   English   中英

無法使用nodeJS從mongodb中刪除特定記錄(文檔)

[英]Cannot Delete specific record(Document) from mongodb using nodeJS

router.get('/deleteRecord/delete/:id', function(req, res){
  db.collection('inventories').remove({_id: mongodb.ObjectID( req.params.id)}, (err, result) => {
    if (err) return console.log(err)
    console.log('Welcome to Delete Function');
    res.redirect('deleteRecord');
  });
});

車把: 刪除

獲取ID,但記錄未刪除

嘗試這個

 db.collection('inventories').find({_id: mongodb.ObjectID( req.params.id)}).remove()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM